Package org.apache.gravitino.job
Interface SupportsJobs
- All Known Implementing Classes:
GravitinoClient
,GravitinoMetalake
public interface SupportsJobs
Interface for job management operations. This interface will be mixed with GravitinoClient to
provide the ability to manage job templates and jobs within the Gravitino system.
-
Method Summary
Modifier and TypeMethodDescriptionCancel a job by its ID.boolean
deleteJobTemplate
(String jobTemplateName) Deletes a job template by its name.Retrieves a job by its ID.getJobTemplate
(String jobTemplateName) Retrieves a job template by its name.listJobs()
Lists all the jobs in Gravitino.Lists all the jobs by the specified job template name.Lists all the registered job templates in Gravitino.void
registerJobTemplate
(JobTemplate jobTemplate) Register a job template with the specified job template to Gravitino.Run a job with the template name and configuration.
-
Method Details
-
listJobTemplates
List<JobTemplate> listJobTemplates()Lists all the registered job templates in Gravitino.- Returns:
- a list of job templates
-
registerJobTemplate
Register a job template with the specified job template to Gravitino. The registered job template will be maintained in Gravitino, allowing it to be executed later.- Parameters:
jobTemplate
- the template for the job- Throws:
JobTemplateAlreadyExistsException
- if a job template with the same name already exists
-
getJobTemplate
Retrieves a job template by its name.- Parameters:
jobTemplateName
- the name of the job template to retrieve- Returns:
- the job template associated with the specified name
- Throws:
NoSuchJobTemplateException
- if no job template with the specified name exists
-
deleteJobTemplate
Deletes a job template by its name. This will remove the job template from Gravitino, and it will no longer be available for execution. Only when all the jobs associated with this job template are completed, failed, or cancelled, the job template can be deleted successfully, otherwise it will throw an exception.The deletion of a job template will also delete all the jobs associated with this template.
- Parameters:
jobTemplateName
- the name of the job template to delete- Returns:
- true if the job template was successfully deleted, false if the job template does not exist
- Throws:
InUseException
- if there are still queued or started jobs associated with the job template
-
listJobs
Lists all the jobs by the specified job template name. This will return a list of job handles associated with the specified job template. Each job handle represents a specific job.- Parameters:
jobTemplateName
- the name of the job template to list jobs for- Returns:
- a list of job handles associated with the specified job template
- Throws:
NoSuchJobTemplateException
- if no job template with the specified name exists
-
listJobs
Lists all the jobs in Gravitino. This will return a list of all job handles, regardless of the job template they are associated with.- Returns:
- a list of all job handles in Gravitino
-
runJob
JobHandle runJob(String jobTemplateName, Map<String, String> jobConf) throws NoSuchJobTemplateExceptionRun a job with the template name and configuration. The jobConf is a map of key-value contains the variables that will be used to replace the templated parameters in the job template.- Parameters:
jobTemplateName
- the name of the job template to runjobConf
- the configuration for the job- Returns:
- a handle to the run job
- Throws:
NoSuchJobTemplateException
- if no job template with the specified name exists
-
getJob
Retrieves a job by its ID.- Parameters:
jobId
- the ID of the job to retrieve- Returns:
- a handle to the job
- Throws:
NoSuchJobException
- if the job with the specified ID does not exist
-
cancelJob
Cancel a job by its ID. This operation will attempt to cancel the job if it is still running. This method will return immediately, user could use the job handle to check the status of the job after invoking this method.- Parameters:
jobId
- the ID of the job to cancel- Returns:
- a handle to the cancelled job
- Throws:
NoSuchJobException
- if the job with the specified ID does not exist
-