本文整理汇总了Java中com.google.api.client.googleapis.batch.json.JsonBatchCallback类的典型用法代码示例。如果您正苦于以下问题:Java JsonBatchCallback类的具体用法?Java JsonBatchCallback怎么用?Java JsonBatchCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JsonBatchCallback类属于com.google.api.client.googleapis.batch.json包,在下文中一共展示了JsonBatchCallback类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performSearchAnalyticsQueryInBatch
import com.google.api.client.googleapis.batch.json.JsonBatchCallback; //导入依赖的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();
}
示例2: queue
import com.google.api.client.googleapis.batch.json.JsonBatchCallback; //导入依赖的package包/类
/**
* Adds an additional request to the batch, and possibly flushes the current contents of the batch
* if {@code maxRequestsPerBatch} has been reached.
*/
public <T> void queue(final StorageRequest<T> req, final JsonBatchCallback<T> callback)
throws IOException {
QueueRequestCallback queueCallback = new QueueRequestCallback() {
@Override
public void enqueue() throws IOException {
req.queue(batch, callback);
}
};
pendingBatchEntries.add(queueCallback);
flushIfPossibleAndRequired();
}
示例3: testDeleteObjectWithGenerationId
import com.google.api.client.googleapis.batch.json.JsonBatchCallback; //导入依赖的package包/类
/**
* Test successful operation of GoogleCloudStorage.delete(2) with generationId.
*/
@Test
public void testDeleteObjectWithGenerationId()
throws IOException {
when(mockBatchFactory.newBatchHelper(any(HttpRequestInitializer.class),
any(Storage.class), any(Long.class))).thenReturn(mockBatchHelper);
when(mockStorage.objects()).thenReturn(mockStorageObjects);
when(mockStorageObjects.delete(eq(BUCKET_NAME), eq(OBJECT_NAME)))
.thenReturn(mockStorageObjectsDelete);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
JsonBatchCallback<Void> callback =
(JsonBatchCallback<Void>) invocationOnMock.getArguments()[1];
callback.onSuccess(null, new HttpHeaders());
return null;
}
}).when(mockBatchHelper).queue(
Matchers.<StorageRequest<Object>>anyObject(),
Matchers.<JsonBatchCallback<Object>>anyObject());
when(mockBatchHelper.isEmpty())
.thenReturn(true);
gcs.deleteObjects(Lists.newArrayList(new StorageResourceId(BUCKET_NAME, OBJECT_NAME, 222L)));
verify(mockBatchFactory).newBatchHelper(any(HttpRequestInitializer.class),
eq(mockStorage), any(Long.class));
verify(mockStorage, atLeastOnce()).objects();
verify(mockStorageObjects).delete(eq(BUCKET_NAME), eq(OBJECT_NAME));
verify(mockStorageObjectsDelete).setIfGenerationMatch(eq(222L));
verify(mockBatchHelper, times(1)).isEmpty();
verify(mockBatchHelper, times(1)).flush();
verify(mockBatchHelper, times(1))
.queue(
Matchers.<StorageRequest<Object>>anyObject(),
Matchers.<JsonBatchCallback<Object>>anyObject());
}
示例4: testCopyObjectsNormalOperationSameBucket
import com.google.api.client.googleapis.batch.json.JsonBatchCallback; //导入依赖的package包/类
/**
* Test successful operation of GoogleCloudStorage.copy(4) where srcBucketName == dstBucketName.
*/
@Test
public void testCopyObjectsNormalOperationSameBucket()
throws IOException {
String dstObjectName = OBJECT_NAME + "-copy";
when(mockBatchFactory.newBatchHelper(any(HttpRequestInitializer.class),
any(Storage.class), any(Long.class))).thenReturn(mockBatchHelper);
when(mockStorage.objects()).thenReturn(mockStorageObjects);
when(mockStorageObjects.copy(
eq(BUCKET_NAME), eq(OBJECT_NAME), eq(BUCKET_NAME), eq(dstObjectName),
(StorageObject) isNull()))
.thenReturn(mockStorageObjectsCopy);
gcs.copy(BUCKET_NAME, ImmutableList.of(OBJECT_NAME),
BUCKET_NAME, ImmutableList.of(dstObjectName));
verify(mockBatchFactory).newBatchHelper(any(HttpRequestInitializer.class),
eq(mockStorage), any(Long.class));
verify(mockStorage).objects();
verify(mockStorageObjects).copy(
eq(BUCKET_NAME), eq(OBJECT_NAME), eq(BUCKET_NAME), eq(dstObjectName),
(StorageObject) isNull());
verify(mockBatchHelper).queue(
eq(mockStorageObjectsCopy), Matchers.<JsonBatchCallback<StorageObject>>anyObject());
verify(mockBatchHelper).flush();
}
示例5: testCopyObjectsNormalOperationDifferentBucket
import com.google.api.client.googleapis.batch.json.JsonBatchCallback; //导入依赖的package包/类
/**
* Test successful operation of GoogleCloudStorage.copy(4) where srcBucketName != dstBucketName.
*/
@Test
public void testCopyObjectsNormalOperationDifferentBucket()
throws IOException {
String dstObjectName = OBJECT_NAME + "-copy";
String dstBucketName = BUCKET_NAME + "-copy";
when(mockBatchFactory.newBatchHelper(any(HttpRequestInitializer.class),
any(Storage.class), any(Long.class))).thenReturn(mockBatchHelper);
when(mockStorage.buckets()).thenReturn(mockStorageBuckets);
when(mockStorageBuckets.get(eq(BUCKET_NAME))).thenReturn(mockStorageBucketsGet);
when(mockStorageBuckets.get(eq(dstBucketName))).thenReturn(mockStorageBucketsGet2);
when(mockStorageBucketsGet.execute())
.thenReturn(new Bucket()
.setName(BUCKET_NAME)
.setTimeCreated(new DateTime(1111L))
.setLocation("us-west-123")
.setStorageClass("class-af4"));
when(mockStorageBucketsGet2.execute())
.thenReturn(new Bucket()
.setName(dstBucketName)
.setTimeCreated(new DateTime(2222L))
.setLocation("us-west-123")
.setStorageClass("class-af4"));
when(mockStorage.objects()).thenReturn(mockStorageObjects);
when(mockStorageObjects.copy(
eq(BUCKET_NAME), eq(OBJECT_NAME), eq(dstBucketName), eq(dstObjectName),
(StorageObject) isNull()))
.thenReturn(mockStorageObjectsCopy);
gcs.copy(BUCKET_NAME, ImmutableList.of(OBJECT_NAME),
dstBucketName, ImmutableList.of(dstObjectName));
verify(mockStorage, times(2)).buckets();
verify(mockStorageBuckets, times(2)).get(any(String.class));
verify(mockStorageBucketsGet).execute();
verify(mockStorageBucketsGet2).execute();
verify(mockBatchFactory).newBatchHelper(any(HttpRequestInitializer.class), eq(mockStorage),
any(Long.class));
verify(mockStorage).objects();
verify(mockStorageObjects).copy(
eq(BUCKET_NAME), eq(OBJECT_NAME), eq(dstBucketName), eq(dstObjectName),
(StorageObject) isNull());
verify(mockBatchHelper).queue(
eq(mockStorageObjectsCopy), Matchers.<JsonBatchCallback<StorageObject>>anyObject());
verify(mockBatchHelper).flush();
}
示例6: performSearchAnalyticsQueryInBatch
import com.google.api.client.googleapis.batch.json.JsonBatchCallback; //导入依赖的package包/类
/**
* Call API in batches
*/
public abstract void performSearchAnalyticsQueryInBatch(List<ProducerJob> jobs,
List<ArrayList<ApiDimensionFilter>> filterList,
List<JsonBatchCallback<SearchAnalyticsQueryResponse>> callbackList,
List<GoogleWebmasterFilter.Dimension> requestedDimensions, int rowLimit)
throws IOException;