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 Summary

    Constructors
    Constructor
    Description
    JobRestController(JobLaunchService jobLaunchService, DataServices dataServices, EntityModelAssemblers entityModelAssemblers, com.netflix.genie.common.internal.util.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 Type
    Method
    Description
    org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.search.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<com.netflix.genie.common.dto.search.JobSearchResult> assembler)
    Get jobs for given filter criteria.
    org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.Job>
    Get job information for given job id.
    List<org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.Application>>
    Get the applications used ot run the job.
    org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.Cluster>
    Get the cluster the job was run on or is currently running on.
    org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.Command>
    Get the command the job was run with or is currently running with.
    org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.JobExecution>
    Get the execution information about a job.
    org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.JobMetadata>
    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<com.netflix.genie.common.dto.JobRequest>
    Get the original job request.
    com.fasterxml.jackson.databind.JsonNode
    Get the status of the given job if it exists.
    void
    killJob(String id, String forwardedFrom, javax.servlet.http.HttpServletRequest request)
    Kill job based on given job ID.
    org.springframework.http.ResponseEntity<Void>
    submitJob(@Valid com.netflix.genie.common.dto.JobRequest jobRequest, String clientHost, String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest)
    Submit a new job.
    org.springframework.http.ResponseEntity<Void>
    submitJob(@Valid com.netflix.genie.common.dto.JobRequest jobRequest, org.springframework.web.multipart.MultipartFile[] attachments, String clientHost, String userAgent, javax.servlet.http.HttpServletRequest httpServletRequest)
    Submit a new job with attachments.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JobRestController

      @Autowired public JobRestController(JobLaunchService jobLaunchService, DataServices dataServices, EntityModelAssemblers entityModelAssemblers, com.netflix.genie.common.internal.util.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 com.netflix.genie.common.dto.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 com.netflix.genie.common.exceptions.GenieException, com.netflix.genie.common.internal.exceptions.checked.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:
      com.netflix.genie.common.exceptions.GenieException - For any error
      com.netflix.genie.common.internal.exceptions.checked.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 com.netflix.genie.common.dto.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 com.netflix.genie.common.exceptions.GenieException, com.netflix.genie.common.internal.exceptions.checked.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:
      com.netflix.genie.common.exceptions.GenieException - For any error
      com.netflix.genie.common.internal.exceptions.checked.GenieCheckedException - For V4 Agent Execution errors
    • getJob

      @GetMapping(value="/{id}", produces="application/hal+json") public org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.Job> getJob(@PathVariable("id") String id) throws com.netflix.genie.common.exceptions.GenieException
      Get job information for given job id.
      Parameters:
      id - id for job to look up
      Returns:
      the Job
      Throws:
      com.netflix.genie.common.exceptions.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<com.netflix.genie.common.dto.search.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<com.netflix.genie.common.dto.search.JobSearchResult> assembler) throws com.netflix.genie.common.exceptions.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:
      com.netflix.genie.common.exceptions.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 com.netflix.genie.common.exceptions.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:
      com.netflix.genie.common.exceptions.GenieServerException - For any error
      com.netflix.genie.common.exceptions.GenieException
    • getJobRequest

      @GetMapping(value="/{id}/request", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.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<com.netflix.genie.common.dto.JobExecution> getJobExecution(@PathVariable("id") String id) throws com.netflix.genie.common.exceptions.GenieException
      Get the execution information about a job.
      Parameters:
      id - The id of the job
      Returns:
      The job execution
      Throws:
      com.netflix.genie.common.exceptions.GenieException - On any internal error
    • getJobMetadata

      @GetMapping(value="/{id}/metadata", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<com.netflix.genie.common.dto.JobMetadata> getJobMetadata(@PathVariable("id") String id) throws com.netflix.genie.common.exceptions.GenieException
      Get the metadata information about a job.
      Parameters:
      id - The id of the job
      Returns:
      The job metadata
      Throws:
      com.netflix.genie.common.exceptions.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<com.netflix.genie.common.dto.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<com.netflix.genie.common.dto.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<com.netflix.genie.common.dto.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 com.netflix.genie.common.exceptions.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
      com.netflix.genie.common.exceptions.GenieException - on any Genie internal error