Class JobRestController
java.lang.Object
com.netflix.genie.web.apis.rest.v3.controllers.JobRestController
REST end-point for supporting jobs.
- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionJobRestController
(JobLaunchService jobLaunchService, DataServices dataServices, EntityModelAssemblers entityModelAssemblers, GenieHostInfo genieHostInfo, org.springframework.web.client.RestTemplate restTemplate, JobDirectoryServerService jobDirectoryServerService, JobsProperties jobsProperties, io.micrometer.core.instrument.MeterRegistry registry, AgentRoutingService agentRoutingService, org.springframework.core.env.Environment environment, AttachmentService attachmentService, JobKillService jobKillService) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<JobSearchResult>>
findJobs
(String id, String name, String user, Set<String> statuses, Set<String> tags, String clusterName, String clusterId, String commandName, String commandId, Long minStarted, Long maxStarted, Long minFinished, Long maxFinished, String grouping, String groupingInstance, org.springframework.data.domain.Pageable page, org.springframework.data.web.PagedResourcesAssembler<JobSearchResult> assembler) Get jobs for given filter criteria.org.springframework.hateoas.EntityModel<Job>
Get job information for given job id.List<org.springframework.hateoas.EntityModel<Application>>
Get the applications used ot run the job.org.springframework.hateoas.EntityModel<Cluster>
getJobCluster
(String id) Get the cluster the job was run on or is currently running on.org.springframework.hateoas.EntityModel<Command>
getJobCommand
(String id) Get the command the job was run with or is currently running with.org.springframework.hateoas.EntityModel<JobExecution>
Get the execution information about a job.org.springframework.hateoas.EntityModel<JobMetadata>
getJobMetadata
(String id) Get the metadata information about a job.void
getJobOutput
(String id, String forwardedFrom, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Get the job output directory.org.springframework.hateoas.EntityModel<JobRequest>
getJobRequest
(String id) Get the original job request.com.fasterxml.jackson.databind.JsonNode
getJobStatus
(String id) Get the status of the given job if it exists.void
Kill job based on given job ID.org.springframework.http.ResponseEntity<Void>
submitJob
(@Valid JobRequest jobRequest, String clientHost, String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest) Submit a new job.org.springframework.http.ResponseEntity<Void>
submitJob
(@Valid JobRequest jobRequest, org.springframework.web.multipart.MultipartFile[] attachments, String clientHost, String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest) Submit a new job with attachments.
-
Constructor Details
-
JobRestController
@Autowired public JobRestController(JobLaunchService jobLaunchService, DataServices dataServices, EntityModelAssemblers entityModelAssemblers, GenieHostInfo genieHostInfo, @Qualifier("genieRestTemplate") org.springframework.web.client.RestTemplate restTemplate, JobDirectoryServerService jobDirectoryServerService, JobsProperties jobsProperties, io.micrometer.core.instrument.MeterRegistry registry, AgentRoutingService agentRoutingService, org.springframework.core.env.Environment environment, AttachmentService attachmentService, JobKillService jobKillService) Constructor.- Parameters:
jobLaunchService
- TheJobLaunchService
implementation to usedataServices
- TheDataServices
instance to useentityModelAssemblers
- The encapsulation of all the V3 resource assemblersgenieHostInfo
- Information about the host that the Genie process is running onrestTemplate
- The rest template for http requestsjobDirectoryServerService
- The service to handle serving back job directory resourcesjobsProperties
- All the properties associated with jobsregistry
- The metrics registry to useagentRoutingService
- Agent routing serviceenvironment
- The application environment to pull dynamic properties fromattachmentService
- The attachment service to use to save attachments.jobKillService
- The service to kill running jobs
-
-
Method Details
-
submitJob
@PostMapping(consumes="application/json") @ResponseStatus(ACCEPTED) public org.springframework.http.ResponseEntity<Void> submitJob(@Valid @RequestBody @Valid JobRequest jobRequest, @RequestHeader(value="X-Forwarded-For",required=false) @Nullable String clientHost, @RequestHeader(value="User-Agent",required=false) @Nullable String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest) throws GenieException, GenieCheckedException Submit a new job.- Parameters:
jobRequest
- The job request informationclientHost
- client host sending the requestuserAgent
- The user agent stringhttpServletRequest
- The http servlet request- Returns:
- The submitted job
- Throws:
GenieException
- For any errorGenieCheckedException
- For V4 Agent Execution errors
-
submitJob
@PostMapping(consumes="multipart/form-data") @ResponseStatus(ACCEPTED) public org.springframework.http.ResponseEntity<Void> submitJob(@Valid @RequestPart("request") @Valid JobRequest jobRequest, @RequestPart(value="attachment",required=false) @Nullable org.springframework.web.multipart.MultipartFile[] attachments, @RequestHeader(value="X-Forwarded-For",required=false) @Nullable String clientHost, @RequestHeader(value="User-Agent",required=false) @Nullable String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest) throws GenieException, GenieCheckedException Submit a new job with attachments.- Parameters:
jobRequest
- The job request informationattachments
- The attachments for the jobclientHost
- client host sending the requestuserAgent
- The user agent stringhttpServletRequest
- The http servlet request- Returns:
- The submitted job
- Throws:
GenieException
- For any errorGenieCheckedException
- For V4 Agent Execution errors
-
getJob
@GetMapping(value="/{id}", produces="application/hal+json") public org.springframework.hateoas.EntityModel<Job> getJob(@PathVariable("id") String id) throws GenieException Get job information for given job id.- Parameters:
id
- id for job to look up- Returns:
- the Job
- Throws:
GenieException
- For any error
-
getJobStatus
@GetMapping(value="/{id}/status", produces="application/json") public com.fasterxml.jackson.databind.JsonNode getJobStatus(@PathVariable("id") String id) throws NotFoundException Get the status of the given job if it exists.- Parameters:
id
- The id of the job to get status for- Returns:
- The status of the job as one of:
JobStatus
- Throws:
NotFoundException
- When no job with id exists
-
findJobs
@GetMapping(produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<JobSearchResult>> findJobs(@RequestParam(value="id",required=false) @Nullable String id, @RequestParam(value="name",required=false) @Nullable String name, @RequestParam(value="user",required=false) @Nullable String user, @RequestParam(value="status",required=false) @Nullable Set<String> statuses, @RequestParam(value="tag",required=false) @Nullable Set<String> tags, @RequestParam(value="clusterName",required=false) @Nullable String clusterName, @RequestParam(value="clusterId",required=false) @Nullable String clusterId, @RequestParam(value="commandName",required=false) @Nullable String commandName, @RequestParam(value="commandId",required=false) @Nullable String commandId, @RequestParam(value="minStarted",required=false) @Nullable Long minStarted, @RequestParam(value="maxStarted",required=false) @Nullable Long maxStarted, @RequestParam(value="minFinished",required=false) @Nullable Long minFinished, @RequestParam(value="maxFinished",required=false) @Nullable Long maxFinished, @RequestParam(value="grouping",required=false) @Nullable String grouping, @RequestParam(value="groupingInstance",required=false) @Nullable String groupingInstance, @PageableDefault(sort="created",direction=DESC) org.springframework.data.domain.Pageable page, org.springframework.data.web.PagedResourcesAssembler<JobSearchResult> assembler) throws GenieException Get jobs for given filter criteria.- Parameters:
id
- id for jobname
- name of job (can be a SQL-style pattern such as HIVE%)user
- user who submitted jobstatuses
- statuses of jobs to findtags
- tags for the jobclusterName
- the name of the clusterclusterId
- the id of the clustercommandName
- the name of the command run by the jobcommandId
- the id of the command run by the jobminStarted
- The time which the job had to start after in order to be return (inclusive)maxStarted
- The time which the job had to start before in order to be returned (exclusive)minFinished
- The time which the job had to finish after in order to be return (inclusive)maxFinished
- The time which the job had to finish before in order to be returned (exclusive)grouping
- The grouping the job should be a member ofgroupingInstance
- The grouping instance the job should be a member ofpage
- page information for jobassembler
- The paged resources assembler to use- Returns:
- successful response, or one with HTTP error code
- Throws:
GenieException
- For any error
-
killJob
@DeleteMapping("/{id}") @ResponseStatus(ACCEPTED) public void killJob(@PathVariable("id") String id, @RequestHeader(name="Genie-Forwarded-From",required=false) @Nullable String forwardedFrom, javax.servlet.http.HttpServletRequest request) throws GenieException Kill job based on given job ID.- Parameters:
id
- id for job to killforwardedFrom
- The host this request was forwarded from if presentrequest
- the servlet request- Throws:
GenieServerException
- For any errorGenieException
-
getJobRequest
@GetMapping(value="/{id}/request", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<JobRequest> getJobRequest(@PathVariable("id") String id) throws NotFoundException Get the original job request.- Parameters:
id
- The id of the job- Returns:
- The job request
- Throws:
NotFoundException
- If no job with id exists
-
getJobExecution
@GetMapping(value="/{id}/execution", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<JobExecution> getJobExecution(@PathVariable("id") String id) throws GenieException Get the execution information about a job.- Parameters:
id
- The id of the job- Returns:
- The job execution
- Throws:
GenieException
- On any internal error
-
getJobMetadata
@GetMapping(value="/{id}/metadata", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<JobMetadata> getJobMetadata(@PathVariable("id") String id) throws GenieException Get the metadata information about a job.- Parameters:
id
- The id of the job- Returns:
- The job metadata
- Throws:
GenieException
- On any internal error- Since:
- 3.3.5
-
getJobCluster
@GetMapping(value="/{id}/cluster", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<Cluster> getJobCluster(@PathVariable("id") String id) throws NotFoundException Get the cluster the job was run on or is currently running on.- Parameters:
id
- The id of the job to get the cluster for- Returns:
- The cluster
- Throws:
NotFoundException
- When either the job or the cluster aren't found
-
getJobCommand
@GetMapping(value="/{id}/command", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<Command> getJobCommand(@PathVariable("id") String id) throws NotFoundException Get the command the job was run with or is currently running with.- Parameters:
id
- The id of the job to get the command for- Returns:
- The command
- Throws:
NotFoundException
- When either the job or the command aren't found
-
getJobApplications
@GetMapping(value="/{id}/applications", produces="application/hal+json") @ResponseStatus(OK) public List<org.springframework.hateoas.EntityModel<Application>> getJobApplications(@PathVariable("id") String id) throws NotFoundException Get the applications used ot run the job.- Parameters:
id
- The id of the job to get the applications for- Returns:
- The applications
- Throws:
NotFoundException
- When either the job or the applications aren't found
-
getJobOutput
@GetMapping({"/{id}/output","/{id}/output/","/{id}/output/**"}) public void getJobOutput(@PathVariable("id") String id, @RequestHeader(name="Genie-Forwarded-From",required=false) @Nullable String forwardedFrom, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws GenieException, NotFoundException Get the job output directory.- Parameters:
id
- The id of the job to get output forforwardedFrom
- The host this request was forwarded from if presentrequest
- the servlet requestresponse
- the servlet response- Throws:
NotFoundException
- When no job with id existsGenieException
- on any Genie internal error
-