当前位置: 首页>>代码示例>>Java>>正文


Java BatchRequest类代码示例

本文整理汇总了Java中com.google.api.client.googleapis.batch.BatchRequest的典型用法代码示例。如果您正苦于以下问题:Java BatchRequest类的具体用法?Java BatchRequest怎么用?Java BatchRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BatchRequest类属于com.google.api.client.googleapis.batch包,在下文中一共展示了BatchRequest类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeGetBatches

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
/**
 * Makes get {@link BatchRequest BatchRequests}.
 *
 * @param paths {@link GcsPath GcsPaths}.
 * @param results mutable {@link List} for return values.
 * @return {@link BatchRequest BatchRequests} to execute.
 * @throws IOException
 */
@VisibleForTesting
List<BatchRequest> makeGetBatches(
    Collection<GcsPath> paths,
    List<StorageObjectOrIOException[]> results) throws IOException {
  List<BatchRequest> batches = new LinkedList<>();
  for (List<GcsPath> filesToGet :
      Lists.partition(Lists.newArrayList(paths), MAX_REQUESTS_PER_BATCH)) {
    BatchRequest batch = createBatchRequest();
    for (GcsPath path : filesToGet) {
      results.add(enqueueGetFileSize(path, batch));
    }
    batches.add(batch);
  }
  return batches;
}
 
开发者ID:apache,项目名称:beam,代码行数:24,代码来源:GcsUtil.java

示例2: makeCopyBatches

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
List<BatchRequest> makeCopyBatches(Iterable<String> srcFilenames, Iterable<String> destFilenames)
    throws IOException {
  List<String> srcList = Lists.newArrayList(srcFilenames);
  List<String> destList = Lists.newArrayList(destFilenames);
  checkArgument(
      srcList.size() == destList.size(),
      "Number of source files %s must equal number of destination files %s",
      srcList.size(),
      destList.size());

  List<BatchRequest> batches = new LinkedList<>();
  BatchRequest batch = createBatchRequest();
  for (int i = 0; i < srcList.size(); i++) {
    final GcsPath sourcePath = GcsPath.fromUri(srcList.get(i));
    final GcsPath destPath = GcsPath.fromUri(destList.get(i));
    enqueueCopy(sourcePath, destPath, batch);
    if (batch.size() >= MAX_REQUESTS_PER_BATCH) {
      batches.add(batch);
      batch = createBatchRequest();
    }
  }
  if (batch.size() > 0) {
    batches.add(batch);
  }
  return batches;
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:GcsUtil.java

示例3: testMakeCopyBatches

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
@Test
public void testMakeCopyBatches() throws IOException {
  GcsUtil gcsUtil = gcsOptionsWithTestCredential().getGcsUtil();

  // Small number of files fits in 1 batch
  List<BatchRequest> batches = gcsUtil.makeCopyBatches(makeStrings("s", 3), makeStrings("d", 3));
  assertThat(batches.size(), equalTo(1));
  assertThat(sumBatchSizes(batches), equalTo(3));

  // 1 batch of files fits in 1 batch
  batches = gcsUtil.makeCopyBatches(makeStrings("s", 100), makeStrings("d", 100));
  assertThat(batches.size(), equalTo(1));
  assertThat(sumBatchSizes(batches), equalTo(100));

  // A little more than 5 batches of files fits in 6 batches
  batches = gcsUtil.makeCopyBatches(makeStrings("s", 501), makeStrings("d", 501));
  assertThat(batches.size(), equalTo(6));
  assertThat(sumBatchSizes(batches), equalTo(501));
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:GcsUtilTest.java

示例4: testMakeRemoveBatches

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
@Test
public void testMakeRemoveBatches() throws IOException {
  GcsUtil gcsUtil = gcsOptionsWithTestCredential().getGcsUtil();

  // Small number of files fits in 1 batch
  List<BatchRequest> batches = gcsUtil.makeRemoveBatches(makeStrings("s", 3));
  assertThat(batches.size(), equalTo(1));
  assertThat(sumBatchSizes(batches), equalTo(3));

  // 1 batch of files fits in 1 batch
  batches = gcsUtil.makeRemoveBatches(makeStrings("s", 100));
  assertThat(batches.size(), equalTo(1));
  assertThat(sumBatchSizes(batches), equalTo(100));

  // A little more than 5 batches of files fits in 6 batches
  batches = gcsUtil.makeRemoveBatches(makeStrings("s", 501));
  assertThat(batches.size(), equalTo(6));
  assertThat(sumBatchSizes(batches), equalTo(501));
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:GcsUtilTest.java

示例5: testMakeGetBatches

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
@Test
public void testMakeGetBatches() throws IOException {
  GcsUtil gcsUtil = gcsOptionsWithTestCredential().getGcsUtil();

  // Small number of files fits in 1 batch
  List<StorageObjectOrIOException[]> results = Lists.newArrayList();
  List<BatchRequest> batches = gcsUtil.makeGetBatches(makeGcsPaths("s", 3), results);
  assertThat(batches.size(), equalTo(1));
  assertThat(sumBatchSizes(batches), equalTo(3));
  assertEquals(3, results.size());

  // 1 batch of files fits in 1 batch
  results = Lists.newArrayList();
  batches = gcsUtil.makeGetBatches(makeGcsPaths("s", 100), results);
  assertThat(batches.size(), equalTo(1));
  assertThat(sumBatchSizes(batches), equalTo(100));
  assertEquals(100, results.size());

  // A little more than 5 batches of files fits in 6 batches
  results = Lists.newArrayList();
  batches = gcsUtil.makeGetBatches(makeGcsPaths("s", 501), results);
  assertThat(batches.size(), equalTo(6));
  assertThat(sumBatchSizes(batches), equalTo(501));
  assertEquals(501, results.size());
}
 
开发者ID:apache,项目名称:beam,代码行数:26,代码来源:GcsUtilTest.java

示例6: performSearchAnalyticsQueryInBatch

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
@Override
public void performSearchAnalyticsQueryInBatch(List<ProducerJob> jobs, List<ArrayList<ApiDimensionFilter>> filterList,
    List<JsonBatchCallback<SearchAnalyticsQueryResponse>> callbackList, List<Dimension> requestedDimensions,
    int rowLimit)
    throws IOException {
  BatchRequest batchRequest = _client.createBatch();

  for (int i = 0; i < jobs.size(); ++i) {
    ProducerJob job = jobs.get(i);
    ArrayList<ApiDimensionFilter> filters = filterList.get(i);
    JsonBatchCallback<SearchAnalyticsQueryResponse> callback = callbackList.get(i);
    _client.createSearchAnalyticsQuery(_siteProperty, job.getStartDate(), job.getEndDate(), requestedDimensions,
        GoogleWebmasterFilter.andGroupFilters(filters), rowLimit, 0).queue(batchRequest, callback);
  }

  batchRequest.execute();
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:18,代码来源:GoogleWebmasterDataFetcherImpl.java

示例7: reboxUnscheduledMessagesWithOutboxLabel

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
public void reboxUnscheduledMessagesWithOutboxLabel(final List<String> scheduledMailIds) throws IOException {

        final List<Message> messagesInOutboxAll = gmail().users().messages()
                .list(me())
                .setLabelIds(Collections.singletonList(getScheduledLabel().getId()))
                .setQuotaUser(getCurrentUserId())
                .setPrettyPrint(shouldBePretty())
                .execute().getMessages();

        if (messagesInOutboxAll != null && messagesInOutboxAll.size() > 0) {
            log.info(String.format("Found %d outbox messages", messagesInOutboxAll.size()));
            // we can't change more than X at once
            // see https://developers.google.com/gmail/api/v1/reference/quota
            final List<List<Message>> partitionedMessagesInOutbox = Lists.partition(messagesInOutboxAll, 5);

            for (final List<Message> messagesInOutbox : partitionedMessagesInOutbox) {
                final BatchRequest br = gmail().batch();
                int messagesToBeProcessed = 0;
                for (final Message messageInOutbox : messagesInOutbox) {
                    if (!scheduledMailIds.contains(messageInOutbox.getId())) {
                        // we found a message with the label that is not scheduled
                        messagesToBeProcessed++;
                        final ModifyMessageRequest mmr = new ModifyMessageRequest()
                                .setAddLabelIds(Collections.singletonList(LABEL_ID_INBOX))
                                .setRemoveLabelIds(Collections.singletonList(getScheduledLabel().getId()));
                        gmail().users().messages().modify(me(), messageInOutbox.getId(), mmr)
                                .setQuotaUser(getCurrentUserId())
                                .setPrettyPrint(shouldBePretty())
                                .queue(br, bc);
                    }
                }

                if (messagesToBeProcessed > 0) {
                    log.info(String.format("Sending %d messages back into inbox", messagesToBeProcessed));
                    br.execute();
                }
            }
        }
    }
 
开发者ID:MailFred,项目名称:mailfred-appengine,代码行数:40,代码来源:Scheduler.java

示例8: makeRemoveBatches

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
List<BatchRequest> makeRemoveBatches(Collection<String> filenames) throws IOException {
  List<BatchRequest> batches = new LinkedList<>();
  for (List<String> filesToDelete :
      Lists.partition(Lists.newArrayList(filenames), MAX_REQUESTS_PER_BATCH)) {
    BatchRequest batch = createBatchRequest();
    for (String file : filesToDelete) {
      enqueueDelete(GcsPath.fromUri(file), batch);
    }
    batches.add(batch);
  }
  return batches;
}
 
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:GcsUtil.java

示例9: sumBatchSizes

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
private static int sumBatchSizes(List<BatchRequest> batches) {
  int ret = 0;
  for (BatchRequest b : batches) {
    ret += b.size();
    assertThat(b.size(), greaterThan(0));
  }
  return ret;
}
 
开发者ID:apache,项目名称:beam,代码行数:9,代码来源:GcsUtilTest.java

示例10: buildBatchRequest

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
private BatchRequest buildBatchRequest(Compute compute) {
  return compute.batch(
    (HttpRequest request) -> {
      request.getHeaders().setUserAgent("halyard " + halyardVersion);
    }
  );
}
 
开发者ID:spinnaker,项目名称:halyard,代码行数:8,代码来源:GoogleBaseImageValidator.java

示例11: createBatchRequest

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
private BatchRequest createBatchRequest() {
  return storageClient.batch(httpRequestInitializer);
}
 
开发者ID:apache,项目名称:beam,代码行数:4,代码来源:GcsUtil.java

示例12: createBatch

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
@Override
public BatchRequest createBatch() {
  return _service.batch();
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:5,代码来源:GoogleWebmasterClientImpl.java

示例13: createBatch

import com.google.api.client.googleapis.batch.BatchRequest; //导入依赖的package包/类
public abstract BatchRequest createBatch(); 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:2,代码来源:GoogleWebmasterClient.java


注:本文中的com.google.api.client.googleapis.batch.BatchRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。