@RestController
@RequestMapping(value="/api/v3/jobs")
public class JobRestController
extends java.lang.Object
Constructor and Description |
---|
JobRestController(JobCoordinatorService jobCoordinatorService,
JobSearchService jobSearchService,
AttachmentService attachmentService,
ApplicationResourceAssembler applicationResourceAssembler,
ClusterResourceAssembler clusterResourceAssembler,
CommandResourceAssembler commandResourceAssembler,
JobResourceAssembler jobResourceAssembler,
JobRequestResourceAssembler jobRequestResourceAssembler,
JobExecutionResourceAssembler jobExecutionResourceAssembler,
JobSearchResultResourceAssembler jobSearchResultResourceAssembler,
java.lang.String hostName,
org.springframework.web.client.RestTemplate restTemplate,
GenieResourceHttpRequestHandler resourceHttpRequestHandler,
JobsProperties jobsProperties,
com.netflix.spectator.api.Registry registry)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
org.springframework.hateoas.PagedResources<JobSearchResultResource> |
findJobs(java.lang.String id,
java.lang.String name,
java.lang.String user,
java.util.Set<java.lang.String> statuses,
java.util.Set<java.lang.String> tags,
java.lang.String clusterName,
java.lang.String clusterId,
java.lang.String commandName,
java.lang.String commandId,
java.lang.Long minStarted,
java.lang.Long maxStarted,
java.lang.Long minFinished,
java.lang.Long maxFinished,
org.springframework.data.domain.Pageable page,
org.springframework.data.web.PagedResourcesAssembler<JobSearchResult> assembler)
Get jobs for given filter criteria.
|
JobResource |
getJob(java.lang.String id)
Get job information for given job id.
|
java.util.List<ApplicationResource> |
getJobApplications(java.lang.String id)
Get the applications used ot run the job.
|
ClusterResource |
getJobCluster(java.lang.String id)
Get the cluster the job was run on or is currently running on.
|
CommandResource |
getJobCommand(java.lang.String id)
Get the command the job was run with or is currently running with.
|
JobExecutionResource |
getJobExecution(java.lang.String id)
Get the execution information about a job.
|
void |
getJobOutput(java.lang.String id,
java.lang.String forwardedFrom,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Get the job output directory.
|
JobRequestResource |
getJobRequest(java.lang.String id)
Get the original job request.
|
com.fasterxml.jackson.databind.JsonNode |
getJobStatus(java.lang.String id)
Get the status of the given job if it exists.
|
void |
killJob(java.lang.String id,
java.lang.String forwardedFrom,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Kill job based on given job ID.
|
org.springframework.http.ResponseEntity<java.lang.Void> |
submitJob(JobRequest jobRequest,
org.springframework.web.multipart.MultipartFile[] attachments,
java.lang.String clientHost,
java.lang.String userAgent,
javax.servlet.http.HttpServletRequest httpServletRequest)
Submit a new job with attachments.
|
org.springframework.http.ResponseEntity<java.lang.Void> |
submitJob(JobRequest jobRequest,
java.lang.String clientHost,
java.lang.String userAgent,
javax.servlet.http.HttpServletRequest httpServletRequest)
Submit a new job.
|
@Autowired public JobRestController(JobCoordinatorService jobCoordinatorService, JobSearchService jobSearchService, AttachmentService attachmentService, ApplicationResourceAssembler applicationResourceAssembler, ClusterResourceAssembler clusterResourceAssembler, CommandResourceAssembler commandResourceAssembler, JobResourceAssembler jobResourceAssembler, JobRequestResourceAssembler jobRequestResourceAssembler, JobExecutionResourceAssembler jobExecutionResourceAssembler, JobSearchResultResourceAssembler jobSearchResultResourceAssembler, java.lang.String hostName, @Qualifier(value="genieRestTemplate") org.springframework.web.client.RestTemplate restTemplate, GenieResourceHttpRequestHandler resourceHttpRequestHandler, JobsProperties jobsProperties, com.netflix.spectator.api.Registry registry)
jobCoordinatorService
- The job coordinator service to use.jobSearchService
- The search service to useattachmentService
- The attachment service to use to save attachments.applicationResourceAssembler
- Assemble application resources out of applicationsclusterResourceAssembler
- Assemble cluster resources out of applicationscommandResourceAssembler
- Assemble cluster resources out of applicationsjobResourceAssembler
- Assemble job resources out of jobsjobRequestResourceAssembler
- Assemble job request resources out of job requestsjobExecutionResourceAssembler
- Assemble job execution resources out of job executionsjobSearchResultResourceAssembler
- Assemble job search resources out of jobshostName
- The hostname this Genie instance is running onrestTemplate
- The rest template for http requestsresourceHttpRequestHandler
- The handler to return requests for static resources on the
Genie File System.jobsProperties
- All the properties associated with jobsregistry
- The metrics registry to use@RequestMapping(method=POST, consumes="application/json") @ResponseStatus(value=ACCEPTED) public org.springframework.http.ResponseEntity<java.lang.Void> submitJob(@RequestBody JobRequest jobRequest, @RequestHeader(value="X-Forwarded-For",required=false) java.lang.String clientHost, @RequestHeader(value="User-Agent",required=false) java.lang.String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest) throws GenieException
jobRequest
- The job request informationclientHost
- client host sending the requestuserAgent
- The user agent stringhttpServletRequest
- The http servlet requestGenieException
- For any error@RequestMapping(method=POST, consumes="multipart/form-data") @ResponseStatus(value=ACCEPTED) public org.springframework.http.ResponseEntity<java.lang.Void> submitJob(@RequestPart(value="request") JobRequest jobRequest, @RequestPart(value="attachment") org.springframework.web.multipart.MultipartFile[] attachments, @RequestHeader(value="X-Forwarded-For",required=false) java.lang.String clientHost, @RequestHeader(value="User-Agent",required=false) java.lang.String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest) throws GenieException
jobRequest
- The job request informationattachments
- The attachments for the jobclientHost
- client host sending the requestuserAgent
- The user agent stringhttpServletRequest
- The http servlet requestGenieException
- For any error@RequestMapping(value="/{id}", method=GET, produces="application/hal+json") public JobResource getJob(@PathVariable(value="id") java.lang.String id) throws GenieException
id
- id for job to look upGenieException
- For any error@RequestMapping(value="/{id}/status", method=GET, produces="application/json") public com.fasterxml.jackson.databind.JsonNode getJobStatus(@PathVariable(value="id") java.lang.String id) throws GenieException
id
- The id of the job to get status forJobStatus
GenieException
- on error@RequestMapping(method=GET, produces="application/hal+json") @ResponseStatus(value=OK) public org.springframework.hateoas.PagedResources<JobSearchResultResource> findJobs(@RequestParam(value="id",required=false) java.lang.String id, @RequestParam(value="name",required=false) java.lang.String name, @RequestParam(value="user",required=false) java.lang.String user, @RequestParam(value="status",required=false) java.util.Set<java.lang.String> statuses, @RequestParam(value="tag",required=false) java.util.Set<java.lang.String> tags, @RequestParam(value="clusterName",required=false) java.lang.String clusterName, @RequestParam(value="clusterId",required=false) java.lang.String clusterId, @RequestParam(value="commandName",required=false) java.lang.String commandName, @RequestParam(value="commandId",required=false) java.lang.String commandId, @RequestParam(value="minStarted",required=false) java.lang.Long minStarted, @RequestParam(value="maxStarted",required=false) java.lang.Long maxStarted, @RequestParam(value="minFinished",required=false) java.lang.Long minFinished, @RequestParam(value="maxFinished",required=false) java.lang.Long maxFinished, @PageableDefault(sort="created",direction=DESC) org.springframework.data.domain.Pageable page, org.springframework.data.web.PagedResourcesAssembler<JobSearchResult> assembler) throws GenieException
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)page
- page information for jobassembler
- The paged resources assembler to useGenieException
- For any error@RequestMapping(value="/{id}", method=DELETE) @ResponseStatus(value=ACCEPTED) public void killJob(@PathVariable(value="id") java.lang.String id, @RequestHeader(name="Genie-Forwarded-From",required=false) java.lang.String forwardedFrom, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws GenieException, java.io.IOException, javax.servlet.ServletException
id
- id for job to killforwardedFrom
- The host this request was forwarded from if presentrequest
- the servlet requestresponse
- the servlet responseGenieException
- For any errorjava.io.IOException
- on redirect errorjavax.servlet.ServletException
- when trying to handle the request@RequestMapping(value="/{id}/request", method=GET, produces="application/hal+json") @ResponseStatus(value=OK) public JobRequestResource getJobRequest(@PathVariable(value="id") java.lang.String id) throws GenieException
id
- The id of the jobGenieException
- On any internal error@RequestMapping(value="/{id}/execution", method=GET, produces="application/hal+json") @ResponseStatus(value=OK) public JobExecutionResource getJobExecution(@PathVariable(value="id") java.lang.String id) throws GenieException
id
- The id of the jobGenieException
- On any internal error@RequestMapping(value="/{id}/cluster", method=GET, produces="application/hal+json") @ResponseStatus(value=OK) public ClusterResource getJobCluster(@PathVariable(value="id") java.lang.String id) throws GenieException
id
- The id of the job to get the cluster forGenieException
- Usually GenieNotFound exception when either the job or the cluster aren't found@RequestMapping(value="/{id}/command", method=GET, produces="application/hal+json") @ResponseStatus(value=OK) public CommandResource getJobCommand(@PathVariable(value="id") java.lang.String id) throws GenieException
id
- The id of the job to get the command forGenieException
- Usually GenieNotFound exception when either the job or the command aren't found@RequestMapping(value="/{id}/applications", method=GET, produces="application/hal+json") @ResponseStatus(value=OK) public java.util.List<ApplicationResource> getJobApplications(@PathVariable(value="id") java.lang.String id) throws GenieException
id
- The id of the job to get the applications forGenieException
- Usually GenieNotFound exception when either the job or the applications aren't found@RequestMapping(value={"/{id}/output","/{id}/output/","/{id}/output/**"}, method=GET, produces="*/*") public void getJobOutput(@PathVariable(value="id") java.lang.String id, @RequestHeader(name="Genie-Forwarded-From",required=false) java.lang.String forwardedFrom, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException, GenieException
id
- The id of the job to get output forforwardedFrom
- The host this request was forwarded from if presentrequest
- the servlet requestresponse
- the servlet responsejava.io.IOException
- on redirect errorjavax.servlet.ServletException
- when trying to handle the requestGenieException
- on any Genie internal error