use of com.google.storage.v2.WriteObjectResponse in project hadoop-connectors by GoogleCloudDataproc.
the class WatchdogTest method watchOnClientStreamingRPCWithoutTimeout.
@Test
public void watchOnClientStreamingRPCWithoutTimeout() {
NoopClientCallStub<WriteObjectRequest, WriteObjectResponse> clientCall = new NoopClientCallStub<>();
StreamObserver<WriteObjectRequest> timeoutStreamObserver = new StreamObserver<>() {
@Override
public void onNext(WriteObjectRequest value) {
logger.atInfo().log("Sleeping for 10 seconds");
sleepUninterruptibly(Duration.ofSeconds(10));
}
@Override
public void onError(Throwable t) {
}
@Override
public void onCompleted() {
}
};
StreamObserver<WriteObjectRequest> watch = watchdog.watch(clientCall, timeoutStreamObserver, zeroWaitTime);
WriteObjectRequest value = WriteObjectRequest.newBuilder().build();
watch.onNext(value);
assertThat(clientCall.cancelled).isFalse();
assertThat(clientCall.cause).isNull();
}
use of com.google.storage.v2.WriteObjectResponse in project hadoop-connectors by GoogleCloudDataproc.
the class GoogleCloudStorageGrpcWriteChannel method handleResponse.
@Override
public void handleResponse(WriteObjectResponse response) {
Object resource = response.getResource();
Map<String, byte[]> metadata = resource.getMetadataMap().entrySet().stream().collect(toMap(Map.Entry::getKey, entry -> BaseEncoding.base64().decode(entry.getValue())));
byte[] md5Hash = null;
byte[] crc32c = null;
if (resource.hasChecksums()) {
md5Hash = !resource.getChecksums().getMd5Hash().isEmpty() ? resource.getChecksums().getMd5Hash().toByteArray() : null;
crc32c = resource.getChecksums().hasCrc32C() ? ByteBuffer.allocate(4).putInt(resource.getChecksums().getCrc32C()).array() : null;
}
completedItemInfo = GoogleCloudStorageItemInfo.createObject(resourceId, Timestamps.toMillis(resource.getCreateTime()), Timestamps.toMillis(resource.getUpdateTime()), resource.getSize(), resource.getContentType(), resource.getContentEncoding(), metadata, resource.getGeneration(), resource.getMetageneration(), new VerificationAttributes(md5Hash, crc32c));
}
Aggregations