Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;

/**
Expand All @@ -67,6 +68,7 @@ final class ByteStreamUploader {
private final long callTimeoutSecs;
private final RemoteRetrier retrier;
private final DigestFunction.Value digestFunction;
private final AtomicBoolean queryWriteStatusImplemented = new AtomicBoolean(true);

@Nullable private final Semaphore openedFilePermits;

Expand Down Expand Up @@ -213,7 +215,7 @@ private AlreadyExists() {
}
}

private static final class AsyncUpload implements AsyncCallable<Long> {
private final class AsyncUpload implements AsyncCallable<Long> {
private final RemoteActionExecutionContext context;
private final ReferenceCountedChannel channel;
private final CallCredentialsProvider callCredentialsProvider;
Expand Down Expand Up @@ -331,6 +333,11 @@ private ByteStreamStub bsAsyncStub(Channel channel) {
}

private ListenableFuture<Long> query() {
if (!queryWriteStatusImplemented.get()) {
// Without server support for QueryWriteStatus, we have no choice but to restart the entire
// upload.
return Futures.immediateFuture(0L);
}
ListenableFuture<Long> committedSizeFuture =
Futures.transformAsync(
channel.withChannelFuture(
Expand All @@ -351,8 +358,7 @@ private ListenableFuture<Long> query() {
(e) -> {
Status status = Status.fromThrowable(e);
if (status.getCode() == Code.UNIMPLEMENTED) {
// if the bytestream server does not implement the query, insist
// that we should reset the upload
queryWriteStatusImplemented.set(false);
return Futures.immediateFuture(0L);
}
return Futures.immediateFailedFuture(e);
Expand Down