public class Job extends JobInfo
Objects of this class are immutable. To get a Job object with the most recent
information use reload(com.google.cloud.bigquery.BigQuery.JobOption...). Job adds a layer of service-related functionality over
JobInfo.
| Modifier and Type | Class and Description |
|---|---|
static class |
Job.Builder
A builder for
Job objects. |
JobInfo.CreateDisposition, JobInfo.WriteDisposition| Modifier and Type | Method and Description |
|---|---|
BigQuery |
bigquery()
Returns the job's
BigQuery object used to issue requests. |
boolean |
cancel()
Sends a job cancel request.
|
boolean |
equals(Object obj) |
boolean |
exists()
Checks if this job exists.
|
int |
hashCode() |
boolean |
isDone()
Checks if this job has completed its execution, either failing or succeeding.
|
Job |
reload(BigQuery.JobOption... options)
Fetches current job's latest information.
|
Job.Builder |
toBuilder()
Returns a builder for the job object.
|
Job |
waitFor(WaitForOption... waitOptions)
Blocks until this job completes its execution, either failing or succeeding.
|
builder, configuration, etag, generatedId, jobId, of, of, selfLink, statistics, status, toString, userEmailpublic boolean exists()
true if this job exists, false otherwiseBigQueryException - upon failurepublic boolean isDone()
true. You can wait for job completion with:
while(!job.isDone()) {
Thread.sleep(1000L);
}true if this job is in JobStatus.State.DONE state or if it does not
exist, false if the state is not JobStatus.State.DONEBigQueryException - upon failurepublic Job waitFor(WaitForOption... waitOptions) throws InterruptedException, TimeoutException
null. By default, the job status is checked every 500 milliseconds, to configure this
value use WaitForOption.checkEvery(long, TimeUnit). Use
WaitForOption.timeout(long, TimeUnit) to set the maximum time to wait.
Example usage of waitFor():
Job completedJob = job.waitFor();
if (completedJob == null) {
// job no longer exists
} else if (completedJob.status().error() != null) {
// job failed, handle error
} else {
// job completed successfully
}
Example usage of waitFor() with checking period and timeout:
Job completedJob = job.waitFor(WaitForOption.checkEvery(1, TimeUnit.SECONDS),
WaitForOption.timeout(60, TimeUnit.SECONDS));
if (completedJob == null) {
// job no longer exists
} else if (completedJob.status().error() != null) {
// job failed, handle error
} else {
// job completed successfully
}waitOptions - options to configure checking period and timeoutBigQueryException - upon failureInterruptedException - if the current thread gets interrupted while waiting for the job
to completeTimeoutException - if the timeout provided with
WaitForOption.timeout(long, TimeUnit) is exceeded. If no such option is provided
this exception is never thrown.public Job reload(BigQuery.JobOption... options)
null if the job does not exist.options - job optionsJob object with latest information or null if not foundBigQueryException - upon failurepublic boolean cancel()
true if cancel request was sent successfully, false if job was not
foundBigQueryException - upon failurepublic BigQuery bigquery()
BigQuery object used to issue requests.public Job.Builder toBuilder()
JobInfoCopyright © 2016 Google. All rights reserved.