/** Example of cancelling a job. */ // [TARGET cancel(String)] // [VARIABLE "my_job_name"] public boolean cancelJob(String jobName) { // [START ] boolean success = bigquery.cancel(jobName); if (success) { // job was cancelled } else { // job was not found } // [END ] return success; }
@Override public void run(BigQuery bigquery, JobId jobId) { if (bigquery.cancel(jobId)) { System.out.println("Requested cancel for job " + jobId); } else { System.out.println("Job " + jobId + " not found"); } } }
/** Example of cancelling a job. */ // [TARGET cancel(JobId)] // [VARIABLE "my_job_name"] public boolean cancelJobFromId(String jobName) { // [START ] JobId jobId = JobId.of(jobName); boolean success = bigquery.cancel(jobId); if (success) { // job was cancelled } else { // job was not found } // [END ] return success; }
/** * Sends a job cancel request. * * <p>Example of cancelling a job. * * <pre>{@code * if (job.cancel()) { * return true; // job successfully cancelled * } else { * // job not found * } * }</pre> * * @return {@code true} if cancel request was sent successfully, {@code false} if job was not * found * @throws BigQueryException upon failure */ public boolean cancel() { checkNotDryRun("cancel"); return bigquery.cancel(getJobId()); }
@Test public void testCancelNonExistingJob() { assertFalse(bigquery.cancel("test_cancel_non_existing_job")); }
@Test public void testCancelJob() { EasyMock.expect(bigqueryRpcMock.cancel(PROJECT, JOB, null)).andReturn(true); EasyMock.replay(bigqueryRpcMock); bigquery = options.getService(); assertTrue(bigquery.cancel(JOB)); }
@Test public void testCancelJobFromJobId() { EasyMock.expect(bigqueryRpcMock.cancel(PROJECT, JOB, null)).andReturn(true); EasyMock.replay(bigqueryRpcMock); bigquery = options.getService(); assertTrue(bigquery.cancel(JobId.of(PROJECT, JOB))); }
@Test public void testCancelJobFromJobIdWithProject() { JobId jobId = JobId.of(OTHER_PROJECT, JOB); EasyMock.expect(bigqueryRpcMock.cancel(OTHER_PROJECT, JOB, null)).andReturn(true); EasyMock.replay(bigqueryRpcMock); bigquery = options.getService(); assertTrue(bigquery.cancel(jobId)); }
@Test public void testCancel() throws Exception { initializeExpectedJob(1); expect(bigquery.getOptions()).andReturn(mockOptions); expect(bigquery.cancel(JOB_INFO.getJobId())).andReturn(true); replay(bigquery); initializeJob(); assertTrue(job.cancel()); }
/** * Sends a job cancel request. * * @return {@code true} if cancel request was sent successfully, {@code false} if job was not * found * @throws BigQueryException upon failure */ public boolean cancel() { return bigquery.cancel(jobId()); }
/** * Sends a job cancel request. * * <p>Example of cancelling a job. * * <pre>{@code * if (job.cancel()) { * return true; // job successfully cancelled * } else { * // job not found * } * }</pre> * * @return {@code true} if cancel request was sent successfully, {@code false} if job was not * found * @throws BigQueryException upon failure */ public boolean cancel() { checkNotDryRun("cancel"); return bigquery.cancel(getJobId()); }