test_class.declarator: mockBigQuery
test_class.modifier: private
test_class.original_string: private Bigquery mockBigQuery;
test_class.type: Bigquery
test_class.var_name: mockBigQuery
test_class.declarator: mockProgressable
test_class.modifier: private
test_class.original_string: private Progressable mockProgressable;
test_class.type: Progressable
test_class.var_name: mockProgressable
test_class.declarator: projectId = "Test"
test_class.modifier: private
test_class.original_string: private String projectId = "Test";
test_class.type: String
test_class.var_name: projectId
test_class.declarator: jobReference
test_class.modifier: private
test_class.original_string: private JobReference jobReference;
test_class.type: JobReference
test_class.var_name: jobReference
test_class.declarator: mockBigQueryJobs
test_class.modifier: private
test_class.original_string: private Bigquery.Jobs mockBigQueryJobs;
test_class.type: Bigquery.Jobs
test_class.var_name: mockBigQueryJobs
test_class.declarator: mockJobsGet
test_class.modifier: private
test_class.original_string: private Bigquery.Jobs.Get mockJobsGet;
test_class.type: Bigquery.Jobs.Get
test_class.var_name: mockJobsGet
test_class.declarator: jobStatus
test_class.modifier: private
test_class.original_string: private JobStatus jobStatus;
test_class.type: JobStatus
test_class.var_name: jobStatus
test_class.declarator: notDoneJobStatus
test_class.modifier: private
test_class.original_string: private JobStatus notDoneJobStatus;
test_class.type: JobStatus
test_class.var_name: notDoneJobStatus
test_class.declarator: job
test_class.modifier: private
test_class.original_string: private Job job;
test_class.type: Job
test_class.var_name: job
test_class.declarator: notDoneJob
test_class.modifier: private
test_class.original_string: private Job notDoneJob;
test_class.type: Job
test_class.var_name: notDoneJob
test_class.file: bigquery/src/test/java/com/google/cloud/hadoop/io/bigquery/BigQueryUtilsTest.java
test_class.identifier: BigQueryUtilsTest
test_case.body: @Test
    public void testWaitForJobCompletionError()
        throws InterruptedException, IOException {
      // Return completed job.
      when(mockJobsGet.execute()).thenReturn(job);
  
      // Set error result to not null.
      jobStatus.setErrorResult(new ErrorProto());
  
      // Run waitForJobCompletion and assert failure.
      IOException e =
          assertThrows(
              IOException.class,
              () ->
                  BigQueryUtils.waitForJobCompletion(
                      mockBigQuery, projectId, jobReference, mockProgressable));
      assertThat(e).hasMessageThat().contains(jobReference.getJobId());
    }
test_case.class_method_signature: BigQueryUtilsTest.testWaitForJobCompletionError()
test_case.full_signature: @Test public void testWaitForJobCompletionError()
test_case.identifier: testWaitForJobCompletionError
test_case.invocations: thenReturn when execute setErrorResult assertThrows waitForJobCompletion contains hasMessageThat assertThat getJobId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWaitForJobCompletionError()
focal_class.declarator: logger = GoogleLogger.forEnclosingClass()
focal_class.modifier: private static final
focal_class.original_string: private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
focal_class.type: GoogleLogger
focal_class.var_name: logger
focal_class.declarator: POLL_WAIT_INITIAL_MILLIS =
        (int) TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS)
focal_class.modifier: public static final
focal_class.original_string: public static final int POLL_WAIT_INITIAL_MILLIS =
        (int) TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS);
focal_class.type: int
focal_class.var_name: POLL_WAIT_INITIAL_MILLIS
focal_class.declarator: POLL_WAIT_INTERVAL_MAX_MILLIS =
        (int) TimeUnit.MILLISECONDS.convert(180, TimeUnit.SECONDS)
focal_class.modifier: public static final
focal_class.original_string: public static final int POLL_WAIT_INTERVAL_MAX_MILLIS =
        (int) TimeUnit.MILLISECONDS.convert(180, TimeUnit.SECONDS);
focal_class.type: int
focal_class.var_name: POLL_WAIT_INTERVAL_MAX_MILLIS
focal_class.declarator: POLL_WAIT_MAX_ELAPSED_MILLIS =
        (int) TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)
focal_class.modifier: public static final
focal_class.original_string: public static final int POLL_WAIT_MAX_ELAPSED_MILLIS =
        (int) TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
focal_class.type: int
focal_class.var_name: POLL_WAIT_MAX_ELAPSED_MILLIS
focal_class.file: bigquery/src/main/java/com/google/cloud/hadoop/io/bigquery/BigQueryUtils.java
focal_class.identifier: BigQueryUtils
focal_class.class_method_signature: BigQueryUtils.waitForJobCompletion(
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
focal_class.full_signature: public static void waitForJobCompletion(
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
focal_class.identifier: waitForJobCompletion
focal_class.modifiers: public static
focal_class.parameters: (
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
focal_class.return: void
focal_class.signature: void waitForJobCompletion(
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
focal_class.class_method_signature: BigQueryUtils.getSchemaFromString(String fields)
focal_class.full_signature: public static List<TableFieldSchema> getSchemaFromString(String fields)
focal_class.identifier: getSchemaFromString
focal_class.modifiers: public static
focal_class.parameters: (String fields)
focal_class.return: List<TableFieldSchema>
focal_class.signature: List<TableFieldSchema> getSchemaFromString(String fields)
focal_method.body: public static void waitForJobCompletion(
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
        throws IOException, InterruptedException {
  
      Sleeper sleeper = Sleeper.DEFAULT;
      BackOff pollBackOff =
          new ExponentialBackOff.Builder()
              .setMaxIntervalMillis(POLL_WAIT_INTERVAL_MAX_MILLIS)
              .setInitialIntervalMillis(POLL_WAIT_INITIAL_MILLIS)
              .setMaxElapsedTimeMillis(POLL_WAIT_MAX_ELAPSED_MILLIS)
              .build();
  
      // Get starting time.
      long startTime = System.currentTimeMillis();
      long elapsedTime = 0;
      boolean notDone = true;
  
      // While job is incomplete continue to poll.
      while (notDone) {
        BackOff operationBackOff = new ExponentialBackOff();
        Get get =
            bigquery
                .jobs()
                .get(projectId, jobReference.getJobId())
                .setLocation(jobReference.getLocation());
  
        Job pollJob =
            ResilientOperation.retry(
                ResilientOperation.getGoogleRequestCallable(get),
                operationBackOff,
                RetryDeterminer.RATE_LIMIT_ERRORS,
                IOException.class,
                sleeper);
  
        elapsedTime = System.currentTimeMillis() - startTime;
        logger.atFine().log(
            "Job status (%s ms) %s: %s",
            elapsedTime, jobReference.getJobId(), pollJob.getStatus().getState());
        if (pollJob.getStatus().getState().equals("DONE")) {
          notDone = false;
          if (pollJob.getStatus().getErrorResult() != null) {
            throw new IOException(
                String.format(
                    "Job %s failed: %s. Errors: %s",
                    jobReference.getJobId(),
                    pollJob.getStatus().getErrorResult(),
                    pollJob.getStatus().getErrors()));
          }
        } else {
          long millisToWait = pollBackOff.nextBackOffMillis();
          if (millisToWait == BackOff.STOP) {
            throw new IOException(
                String.format(
                    "Job %s failed to complete after %s millis.",
                    jobReference.getJobId(), elapsedTime));
          }
          // Pause execution for the configured duration before polling job status again.
          Thread.sleep(millisToWait);
          // Call progress to ensure task doesn't time out.
          progressable.progress();
        }
      }
    }
focal_method.class_method_signature: BigQueryUtils.waitForJobCompletion(
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
focal_method.full_signature: public static void waitForJobCompletion(
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
focal_method.identifier: waitForJobCompletion
focal_method.invocations: build setMaxElapsedTimeMillis setInitialIntervalMillis setMaxIntervalMillis currentTimeMillis setLocation get jobs getJobId getLocation retry getGoogleRequestCallable currentTimeMillis log atFine getJobId getState getStatus equals getState getStatus getErrorResult getStatus format getJobId getErrorResult getStatus getErrors getStatus nextBackOffMillis format getJobId sleep progress
focal_method.modifiers: public static
focal_method.parameters: (
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)
focal_method.return: void
focal_method.signature: void waitForJobCompletion(
        Bigquery bigquery, String projectId, JobReference jobReference, Progressable progressable)