Another job, running right now: Sleeping 2 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 4 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 8 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 16 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 32 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 64 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 128 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 256 seconds... Batch job ID 455533540 has status 'ACTIVE'. Sleeping 512 seconds...
On Monday, March 6, 2017 at 12:39:42 PM UTC+2, di...@easyleads.com wrote: > > Hi, > > Our software manages customers budgets and as result it performs a lot of > BudgetOperations, thus the performance is critical. > > I just had a job that updates budgets/delivery methods of 15 campaigns and > it took several minutes. > > Am I doing something wrong? > > Thanks > > Job ID is 455295008 > > Output: > Sleeping 2 seconds... > Batch job ID 455295008 has status 'ACTIVE'. > Sleeping 4 seconds... > Batch job ID 455295008 has status 'ACTIVE'. > Sleeping 8 seconds... > Batch job ID 455295008 has status 'ACTIVE'. > Sleeping 16 seconds... > Batch job ID 455295008 has status 'ACTIVE'. > Sleeping 32 seconds... > Batch job ID 455295008 has status 'ACTIVE'. > Sleeping 64 seconds... > Batch job ID 455295008 has status 'ACTIVE'. > Sleeping 128 seconds... > Batch job ID 455295008 has status 'ACTIVE'. > Sleeping 256 seconds... > Batch job ID 455295008 has status 'DONE'. > > Code: > BatchJobServiceInterface batchJobService = adwordsServices.get(session, > BatchJobServiceInterface.class); > // Create a BatchJob. > BatchJobOperation addOp = new BatchJobOperation(); > addOp.setOperator(Operator.ADD); > addOp.setOperand(new BatchJob()); > BatchJob batchJob = batchJobService.mutate(new BatchJobOperation[] > {addOp}).getValue(0); > // Get the upload URL from the new job. > String uploadUrl = batchJob.getUploadUrl().getUrl(); > > // Use a BatchJobHelper to upload all operations. > BatchJobHelper batchJobHelper = new BatchJobHelper(session); > > batchJobHelper.uploadBatchJobOperations(operations, uploadUrl); > > List<BatchJobStatus> pendingStatuses = > Arrays.asList(BatchJobStatus.ACTIVE, BatchJobStatus.AWAITING_FILE); > int pollAttempts = 0; > boolean isPending = true; > Selector selector = new SelectorBuilder(). > fields(BatchJobField.Id, BatchJobField.Status, BatchJobField.DownloadUrl, > BatchJobField.ProcessingErrors, BatchJobField.ProgressStats) > .equalsId(batchJob.getId()) > .build(); > int initialWait = 2; > if(operations.size() > 100){ > if(operations.size() < 200){ > initialWait = 4; > } > else if(operations.size() < 500){ > initialWait = 6; > } > else{ > initialWait = 10; > } > } > > do { > long sleepSeconds = (long)(Math.scalb(initialWait, pollAttempts)); > System.out.printf("Sleeping %d seconds...%n", sleepSeconds); > Thread.sleep(sleepSeconds * 1000); > > batchJob = batchJobService.get(selector).getEntries(0); > System.out.printf("Batch job ID %d has status '%s'.%n", batchJob.getId(), > batchJob.getStatus()); > > pollAttempts++; > isPending = pendingStatuses.contains(batchJob.getStatus()); > } while (isPending && pollAttempts < 10); > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and Google+: https://googleadsdeveloper.blogspot.com/ https://plus.google.com/+GoogleAdsDevelopers/posts =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/d55b4e60-0061-4be8-9f8e-a62a0af9629d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.