@Override public void addGet( StorageObject storageObject, RpcBatch.Callback<StorageObject> callback, Map<Option, ?> options) { try { if (currentBatchSize == MAX_BATCH_SIZE) { batches.add(storage.batch()); currentBatchSize = 0; } getCall(storageObject, options).queue(batches.getLast(), toJsonCallback(callback)); currentBatchSize++; } catch (IOException ex) { throw translate(ex); } }
@Override public void addGet( StorageObject storageObject, RpcBatch.Callback<StorageObject> callback, Map<Option, ?> options) { try { if (currentBatchSize == MAX_BATCH_SIZE) { batches.add(storage.batch()); currentBatchSize = 0; } getCall(storageObject, options).queue(batches.getLast(), toJsonCallback(callback)); currentBatchSize++; } catch (IOException ex) { throw translate(ex); } }
getRequest(tuple.x(), tuple.y()).queue(batch, new JsonBatchCallback<StorageObject>() { @Override public void onSuccess(StorageObject storageObject, HttpHeaders responseHeaders) {
private StorageObjectOrIOException[] enqueueGetFileSize(final GcsPath path, BatchRequest batch) throws IOException { final StorageObjectOrIOException[] ret = new StorageObjectOrIOException[1]; Storage.Objects.Get getRequest = storageClient.objects().get(path.getBucket(), path.getObject()); getRequest.queue( batch, new JsonBatchCallback<StorageObject>() { @Override public void onSuccess(StorageObject response, HttpHeaders httpHeaders) throws IOException { ret[0] = StorageObjectOrIOException.create(response); } @Override public void onFailure(GoogleJsonError e, HttpHeaders httpHeaders) throws IOException { IOException ioException; if (errorExtractor.itemNotFound(e)) { ioException = new FileNotFoundException(path.toString()); } else { ioException = new IOException(String.format("Error trying to get %s: %s", path, e)); } ret[0] = StorageObjectOrIOException.create(ioException); } }); return ret; }