Class JobRestController

java.lang.Object
com.netflix.genie.web.apis.rest.v3.controllers.JobRestController

@RestController @RequestMapping("/api/v3/jobs") public class JobRestController extends Object
REST end-point for supporting jobs.
Since:
3.0.0
  • 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 - The JobLaunchService implementation to use
      dataServices - The DataServices instance to use
      entityModelAssemblers - The encapsulation of all the V3 resource assemblers
      genieHostInfo - Information about the host that the Genie process is running on
      restTemplate - The rest template for http requests
      jobDirectoryServerService - The service to handle serving back job directory resources
      jobsProperties - All the properties associated with jobs
      registry - The metrics registry to use
      agentRoutingService - Agent routing service
      environment - The application environment to pull dynamic properties from
      attachmentService - 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 information
      clientHost - client host sending the request
      userAgent - The user agent string
      httpServletRequest - The http servlet request
      Returns:
      The submitted job
      Throws:
      GenieException - For any error
      GenieCheckedException - 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 information
      attachments - The attachments for the job
      clientHost - client host sending the request
      userAgent - The user agent string
      httpServletRequest - The http servlet request
      Returns:
      The submitted job
      Throws:
      GenieException - For any error
      GenieCheckedException - 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 job
      name - name of job (can be a SQL-style pattern such as HIVE%)
      user - user who submitted job
      statuses - statuses of jobs to find
      tags - tags for the job
      clusterName - the name of the cluster
      clusterId - the id of the cluster
      commandName - the name of the command run by the job
      commandId - the id of the command run by the job
      minStarted - 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 of
      groupingInstance - The grouping instance the job should be a member of
      page - page information for job
      assembler - 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 kill
      forwardedFrom - The host this request was forwarded from if present
      request - the servlet request
      Throws:
      GenieServerException - For any error
      GenieException
    • 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 for
      forwardedFrom - The host this request was forwarded from if present
      request - the servlet request
      response - the servlet response
      Throws:
      NotFoundException - When no job with id exists
      GenieException - on any Genie internal error