Skip to content

Commit

Permalink
removing accidental commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-munro committed Oct 16, 2024
1 parent bb7e011 commit 38483ea
Showing 1 changed file with 4 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.retrying.StreamResumptionStrategy;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.HeaderProvider;
import com.google.api.gax.rpc.NoHeaderProvider;
Expand Down Expand Up @@ -99,7 +98,6 @@
import java.util.Objects;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.threeten.bp.Duration;

/** @since 2.14.0 This new api is in preview and is subject to breaking changes. */
Expand Down Expand Up @@ -337,18 +335,12 @@ private Tuple<StorageSettings, Opts<UserProject>> resolveSettingsAndOpts() throw
.startResumableWriteSettings()
.setRetrySettings(baseRetrySettings)
.setRetryableCodes(startResumableWriteRetryableCodes);
// for ReadObject we are configuring the server stream handling to do its own retries, so wire
// things through. Retryable codes will be controlled closer to the use site as idempotency
// considerations need to be made.
// for ReadObject disable retries and move the total timeout to the idle timeout
builder
.readObjectSettings()
.setRetrySettings(readRetrySettings)
// even though we might want to default to the empty set for retryable codes, don't ever
// actually do this. Doing so prevents any retry capability from being wired into the stream
// pipeline, ever.
// For our use, we will always set it one way or the other to ensure it's appropriate
// DO NOT: .setRetryableCodes(Collections.emptySet())
.setResumptionStrategy(new ReadObjectResumptionStrategy())
// disable gapic retries because we're handling it ourselves
.setRetryableCodes(Collections.emptySet())
// for reads, the stream can be held open for a long time in order to read all bytes,
// this is totally valid. instead we want to monitor if the stream is doing work and if not
// timeout.
Expand Down Expand Up @@ -708,7 +700,7 @@ public Duration getTerminationAwaitDuration() {
/** @since 2.14.0 This new api is in preview and is subject to breaking changes. */
@BetaApi
public boolean isAttemptDirectPath() {
return false;
return true;
}

/** @since 2.41.0 This new api is in preview and is subject to breaking changes. */
Expand Down Expand Up @@ -856,40 +848,6 @@ public ServiceRpc create(StorageOptions options) {
}
}

// TODO: See if we can change gax to allow shifting this to callable.withContext so it doesn't
// have to be set globally
private static class ReadObjectResumptionStrategy
implements StreamResumptionStrategy<ReadObjectRequest, ReadObjectResponse> {
private long readOffset = 0;

@NonNull
@Override
public StreamResumptionStrategy<ReadObjectRequest, ReadObjectResponse> createNew() {
return new ReadObjectResumptionStrategy();
}

@NonNull
@Override
public ReadObjectResponse processResponse(ReadObjectResponse response) {
readOffset += response.getChecksummedData().getContent().size();
return response;
}

@Nullable
@Override
public ReadObjectRequest getResumeRequest(ReadObjectRequest originalRequest) {
if (readOffset != 0) {
return originalRequest.toBuilder().setReadOffset(readOffset).build();
}
return originalRequest;
}

@Override
public boolean canResume() {
return true;
}
}

// setInternalHeaderProvider is protected so we need to open its scope in order to set it
// we are adding an entry for gccl which is set via this provider
private static final class GapicStorageSettingsBuilder extends StorageSettings.Builder {
Expand Down

0 comments on commit 38483ea

Please sign in to comment.