Class JobClient
- Since:
- 3.0.0
-
Constructor Summary
ConstructorDescriptionJobClient
(@NotEmpty String url, List<okhttp3.Interceptor> interceptors, GenieNetworkConfiguration genieNetworkConfiguration) Deprecated.JobClient
(@NotNull retrofit2.Retrofit retrofit, int maxStatusRetries) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionMethod to get a job from Genie.getJobApplications
(String jobId) Method to get the Applications for the job.getJobCluster
(String jobId) Method to get the cluster on which the job executes.getJobCommand
(String jobId) Method to get the command on which the job executes.getJobExecution
(String jobId) Method to get the Job Execution information for the job.getJobMetadata
(String jobId) Method to get the metadata information for the job.getJobOutputFile
(String jobId, String outputFilePath) Method to fetch an output file for a job from Genie.getJobOutputFile
(String jobId, String outputFilePath, Long rangeStart, Long rangeEnd) Method to fetch an output file for a job from Genie and accepting an range of bytes to return.getJobRequest
(String jobId) Method to get the Job Request for the job.getJobs()
Method to get a list of all the jobs.getJobs
(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) Deprecated.getJobs
(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) getJobs
(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, @Min(1L) Integer pageSize, SortAttribute sortAttribute, SortDirection sortDirection, @Min(0L) Integer pageIndex) Method to get a list of all the jobs from Genie for the query parameters specified.getJobStatus
(String jobId) Method to fetch the status of a job.getJobStderr
(String jobId) Method to fetch the stderr of a job from Genie.getJobStderr
(String jobId, Long rangeStart, Long rangeEnd) Method to fetch the stderr of a job from Genie.getJobStdout
(String jobId) Method to fetch the stdout of a job from Genie.getJobStdout
(String jobId, Long rangeStart, Long rangeEnd) Method to fetch the stdout of a job from Genie.void
Method to send a kill job request to Genie.submitJob
(JobRequest jobRequest) Submit a job to genie using the jobRequest provided.submitJob
(JobRequest jobRequest, String upstreamSecurityTokenName, String upstreamSecurityTokenValue) Submit a job to genie using the jobRequest and upstream security token information.submitJobWithAttachments
(JobRequest jobRequest, Map<String, InputStream> attachments) Submit a job to genie using the jobRequest and attachments provided.submitJobWithAttachments
(JobRequest jobRequest, Map<String, InputStream> attachments, String upstreamSecurityTokenName, String upstreamSecurityTokenValue) Submit a job to genie using the jobRequest and attachments provided with the upstream security information.waitForCompletion
(String jobId, long blockTimeout) Wait for job to complete, until the given timeout.waitForCompletion
(String jobId, long blockTimeout, long pollTime) Wait for job to complete, until the given timeout.
-
Constructor Details
-
JobClient
public JobClient(@NotNull @NotNull retrofit2.Retrofit retrofit, int maxStatusRetries) Constructor.- Parameters:
retrofit
- The configuredRetrofit
client to a Genie servermaxStatusRetries
- The maximum number of retries to check for job status
-
JobClient
@Deprecated public JobClient(@NotEmpty @NotEmpty String url, @Nullable List<okhttp3.Interceptor> interceptors, @Nullable GenieNetworkConfiguration genieNetworkConfiguration) throws GenieClientException Deprecated.Constructor.- Parameters:
url
- The endpoint URL of the Genie API. Not null or emptyinterceptors
- Any interceptors to configure the client with, can include security onesgenieNetworkConfiguration
- The network configuration parameters. Could be null- Throws:
GenieClientException
- On error
-
-
Method Details
-
submitJob
Submit a job to genie using the jobRequest provided.- Parameters:
jobRequest
- A job request containing all the details for running a job.- Returns:
- jobId The id of the job submitted.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
submitJob
public String submitJob(JobRequest jobRequest, String upstreamSecurityTokenName, String upstreamSecurityTokenValue) throws IOException Submit a job to genie using the jobRequest and upstream security token information.- Parameters:
jobRequest
- A job request containing all the details for running a job.upstreamSecurityTokenName
- the security token name provided by upstream.upstreamSecurityTokenValue
- the security token value provided by upstream.- Returns:
- jobId The id of the job submitted.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
submitJobWithAttachments
public String submitJobWithAttachments(JobRequest jobRequest, Map<String, InputStream> attachments) throws IOExceptionSubmit a job to genie using the jobRequest and attachments provided.- Parameters:
jobRequest
- A job request containing all the details for running a job.attachments
- A map of filenames/input-streams needed to be sent to the server as attachments.- Returns:
- jobId The id of the job submitted.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
submitJobWithAttachments
public String submitJobWithAttachments(JobRequest jobRequest, Map<String, InputStream> attachments, String upstreamSecurityTokenName, String upstreamSecurityTokenValue) throws IOExceptionSubmit a job to genie using the jobRequest and attachments provided with the upstream security information.- Parameters:
jobRequest
- A job request containing all the details for running a job.attachments
- A map of filenames/input-streams needed to be sent to the server as attachments.upstreamSecurityTokenName
- the security token name provided by upstream.upstreamSecurityTokenValue
- the security token value provided by upstream.- Returns:
- jobId The id of the job submitted.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobs
Method to get a list of all the jobs.- Returns:
- A list of jobs.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobs
@Deprecated public List<JobSearchResult> getJobs(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) throws IOException, GenieClientException Deprecated.Method to get a list of all the jobs from Genie for the query parameters specified.Deprecated: For new search fields
- 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)- Returns:
- A list of jobs.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.- See Also:
-
getJobs
public List<JobSearchResult> getJobs(@Nullable String id, @Nullable String name, @Nullable String user, @Nullable Set<String> statuses, @Nullable Set<String> tags, @Nullable String clusterName, @Nullable String clusterId, @Nullable String commandName, @Nullable String commandId, @Nullable Long minStarted, @Nullable Long maxStarted, @Nullable Long minFinished, @Nullable Long maxFinished, @Nullable String grouping, @Nullable String groupingInstance) throws IOException, GenieClientException Method to get a list of all the jobs from Genie for the query parameters specified.- 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 of- Returns:
- A list of jobs.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJobs
public List<JobSearchResult> getJobs(@Nullable String id, @Nullable String name, @Nullable String user, @Nullable Set<String> statuses, @Nullable Set<String> tags, @Nullable String clusterName, @Nullable String clusterId, @Nullable String commandName, @Nullable String commandId, @Nullable Long minStarted, @Nullable Long maxStarted, @Nullable Long minFinished, @Nullable Long maxFinished, @Nullable String grouping, @Nullable String groupingInstance, @Nullable @Min(1L) @Min(1L) Integer pageSize, @Nullable SortAttribute sortAttribute, @Nullable SortDirection sortDirection, @Nullable @Min(0L) @Min(0L) Integer pageIndex) throws IOException, GenieClientException Method to get a list of all the jobs from Genie for the query parameters specified.- 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 ofpageSize
- The maximum number of results returnedsortAttribute
- The entity attribute used to sortsortDirection
- The sort directionpageIndex
- The page index- Returns:
- A list of jobs.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJob
Method to get a job from Genie.- Parameters:
jobId
- The id of the job to get.- Returns:
- The job details.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJobCluster
Method to get the cluster on which the job executes.- Parameters:
jobId
- The id of the job.- Returns:
- The cluster object.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobCommand
Method to get the command on which the job executes.- Parameters:
jobId
- The id of the job.- Returns:
- The command object.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobRequest
Method to get the Job Request for the job.- Parameters:
jobId
- The id of the job.- Returns:
- The job requests object.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobExecution
Method to get the Job Execution information for the job.- Parameters:
jobId
- The id of the job.- Returns:
- The job execution object.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobMetadata
Method to get the metadata information for the job.- Parameters:
jobId
- The id of the job.- Returns:
- The metadata object.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobApplications
Method to get the Applications for the job.- Parameters:
jobId
- The id of the job.- Returns:
- The list of Applications.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
getJobStdout
Method to fetch the stdout of a job from Genie.- Parameters:
jobId
- The id of the job whose output is desired.- Returns:
- An input stream to the output contents.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJobStdout
public InputStream getJobStdout(String jobId, @Nullable Long rangeStart, @Nullable Long rangeEnd) throws IOException, GenieClientException Method to fetch the stdout of a job from Genie.Range Logic:
rangeStart but no rangeEnd then go from the start byte to the end of available content
rangeStart and rangeEnd return that range of bytes from the file if they exist
If only rangeEnd then return the last number of those bytes from the file if they exist
- Parameters:
jobId
- The id of the job whose output is desired.rangeStart
- The start byte of the file to retrieve. Optional. Greater than or equal to 0.rangeEnd
- The end byte of the file to retrieve. Optional. Greater than or equal to 0. Must be greater than rangeStart.- Returns:
- An input stream to the output contents.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJobStderr
Method to fetch the stderr of a job from Genie.- Parameters:
jobId
- The id of the job whose stderr is desired.- Returns:
- An input stream to the stderr contents.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJobStderr
public InputStream getJobStderr(String jobId, @Nullable Long rangeStart, @Nullable Long rangeEnd) throws IOException, GenieClientException Method to fetch the stderr of a job from Genie.Range Logic:
rangeStart but no rangeEnd then go from the start byte to the end of available content
rangeStart and rangeEnd return that range of bytes from the file if they exist
If only rangeEnd then return the last number of those bytes from the file if they exist
- Parameters:
jobId
- The id of the job whose stderr is desired.rangeStart
- The start byte of the file to retrieve. Optional. Greater than or equal to 0.rangeEnd
- The end byte of the file to retrieve. Optional. Greater than or equal to 0. Must be greater than rangeStart.- Returns:
- An input stream to the stderr contents.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJobOutputFile
public InputStream getJobOutputFile(String jobId, String outputFilePath) throws IOException, GenieClientException Method to fetch an output file for a job from Genie.NOTE: If the specified outputFilePath is a directory, then the directory manifest is returned.
- Parameters:
jobId
- The id of the job whose output file is desired.outputFilePath
- The path to the file within output directory.- Returns:
- An input stream to the output file contents.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
getJobOutputFile
public InputStream getJobOutputFile(String jobId, String outputFilePath, @Nullable Long rangeStart, @Nullable Long rangeEnd) throws IOException, GenieClientException Method to fetch an output file for a job from Genie and accepting an range of bytes to return.NOTE: If the specified outputFilePath is a directory, then the directory manifest is returned.
Range Logic:
rangeStart but no rangeEnd then go from the start byte to the end of available content
rangeStart and rangeEnd return that range of bytes from the file if they exist
If only rangeEnd then return the last number of those bytes from the file if they exist
- Parameters:
jobId
- The id of the job whose output file is desired.outputFilePath
- The path to the file within output directory.rangeStart
- The start byte of the file to retrieve. Optional. Greater than or equal to 0.rangeEnd
- The end byte of the file to retrieve. Optional. Greater than or equal to 0. Must be greater than rangeStart.- Returns:
- An input stream to the output file contents.
- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.- See Also:
-
getJobStatus
Method to fetch the status of a job.- Parameters:
jobId
- The id of the job.- Returns:
- The status of the Job.
- Throws:
GenieClientException
- If the response recieved is not 2xx.IOException
- For Network and other IO issues.
-
killJob
Method to send a kill job request to Genie.- Parameters:
jobId
- The id of the job.- Throws:
GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.
-
waitForCompletion
public JobStatus waitForCompletion(String jobId, long blockTimeout, long pollTime) throws GenieClientException, InterruptedException, IOException, GenieTimeoutException Wait for job to complete, until the given timeout.- Parameters:
jobId
- the Genie job ID to wait for completionblockTimeout
- the time to block for (in ms), after which a GenieClientException will be thrownpollTime
- the time to sleep between polling for job status- Returns:
- The job status for the job after completion
- Throws:
InterruptedException
- on thread errors.GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.GenieTimeoutException
- If the job times out.
-
waitForCompletion
public JobStatus waitForCompletion(String jobId, long blockTimeout) throws GenieClientException, InterruptedException, IOException, GenieTimeoutException Wait for job to complete, until the given timeout.- Parameters:
jobId
- the Genie job ID to wait for completion.blockTimeout
- the time to block for (in ms), after which a GenieClientException will be thrown.- Returns:
- The job status for the job after completion.
- Throws:
InterruptedException
- on thread errors.GenieClientException
- If the response received is not 2xx.IOException
- For Network and other IO issues.GenieTimeoutException
- If the job times out.
-
JobClient(Retrofit, int)