Skip to content

Commit

Permalink
chore: name cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWhitehead committed Jul 24, 2023
1 parent fa3ad2f commit 7df353b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import java.io.IOException;
import java.time.Clock;

public abstract class StorageWriterConfig {
public abstract class BlobWriteSessionConfig {

@InternalApi
StorageWriterConfig() {}
BlobWriteSessionConfig() {}

@InternalApi
abstract WriterFactory createFactory(Clock clock) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import com.google.api.core.BetaApi;

@BetaApi
public final class StorageWriterConfigs {
public final class BlobWriteSessionConfigs {

private StorageWriterConfigs() {}
private BlobWriteSessionConfigs() {}

@BetaApi
public static DefaultStorageWriterConfig getDefault() {
return new DefaultStorageWriterConfig(ByteSizeConstants._16MiB);
public static DefaultBlobWriteSessionConfig getDefault() {
return new DefaultBlobWriteSessionConfig(ByteSizeConstants._16MiB);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
*/
@Immutable
@BetaApi
public final class DefaultStorageWriterConfig extends StorageWriterConfig {
public final class DefaultBlobWriteSessionConfig extends BlobWriteSessionConfig {

private final int chunkSize;

@InternalApi
DefaultStorageWriterConfig(int chunkSize) {
DefaultBlobWriteSessionConfig(int chunkSize) {
this.chunkSize = chunkSize;
}

Expand All @@ -56,12 +56,12 @@ public int getChunkSize() {
}

@BetaApi
public DefaultStorageWriterConfig withChunkSize(int chunkSize) {
public DefaultBlobWriteSessionConfig withChunkSize(int chunkSize) {
Preconditions.checkArgument(
chunkSize >= ByteSizeConstants._256KiB,
"chunkSize must be >= %d",
ByteSizeConstants._256KiB);
return new DefaultStorageWriterConfig(chunkSize);
return new DefaultBlobWriteSessionConfig(chunkSize);
}

@Override
Expand Down Expand Up @@ -96,7 +96,7 @@ public WritableByteChannelSession<?, BlobInfo> writeSession(
writer.newLazyWriteChannel().getSession();
return new DecoratedWritableByteChannelSession<>(session, d);
}
return CrossTransportUtils.throwGrpcOnly(DefaultStorageWriterConfig.class, "");
return CrossTransportUtils.throwGrpcOnly(DefaultBlobWriteSessionConfig.class, "");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
import com.google.cloud.Policy;
import com.google.cloud.WriteChannel;
import com.google.cloud.storage.Acl.Entity;
import com.google.cloud.storage.BlobWriteSessionConfig.WriterFactory;
import com.google.cloud.storage.BufferedWritableByteChannelSession.BufferedWritableByteChannel;
import com.google.cloud.storage.Conversions.Decoder;
import com.google.cloud.storage.HmacKey.HmacKeyMetadata;
import com.google.cloud.storage.HmacKey.HmacKeyState;
import com.google.cloud.storage.PostPolicyV4.PostConditionsV4;
import com.google.cloud.storage.PostPolicyV4.PostFieldsV4;
import com.google.cloud.storage.Storage.ComposeRequest.SourceBlob;
import com.google.cloud.storage.StorageWriterConfig.WriterFactory;
import com.google.cloud.storage.UnbufferedReadableByteChannelSession.UnbufferedReadableByteChannel;
import com.google.cloud.storage.UnbufferedWritableByteChannelSession.UnbufferedWritableByteChannel;
import com.google.cloud.storage.UnifiedOpts.BucketListOpt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public final class GrpcStorageOptions extends StorageOptions
private final Duration terminationAwaitDuration;
private final boolean attemptDirectPath;
private final GrpcInterceptorProvider grpcInterceptorProvider;
private final StorageWriterConfig storageWriterConfig;
private final BlobWriteSessionConfig blobWriteSessionConfig;

private GrpcStorageOptions(Builder builder, GrpcStorageDefaults serviceDefaults) {
super(builder, serviceDefaults);
Expand All @@ -96,7 +96,7 @@ private GrpcStorageOptions(Builder builder, GrpcStorageDefaults serviceDefaults)
builder.terminationAwaitDuration, serviceDefaults.getTerminationAwaitDuration());
this.attemptDirectPath = builder.attemptDirectPath;
this.grpcInterceptorProvider = builder.grpcInterceptorProvider;
this.storageWriterConfig = builder.storageWriterConfig;
this.blobWriteSessionConfig = builder.blobWriteSessionConfig;
}

@Override
Expand Down Expand Up @@ -349,7 +349,7 @@ public static final class Builder extends StorageOptions.Builder {
private boolean attemptDirectPath = GrpcStorageDefaults.INSTANCE.isAttemptDirectPath();
private GrpcInterceptorProvider grpcInterceptorProvider =
GrpcStorageDefaults.INSTANCE.grpcInterceptorProvider();
private StorageWriterConfig storageWriterConfig =
private BlobWriteSessionConfig blobWriteSessionConfig =
GrpcStorageDefaults.INSTANCE.getDefaultStorageWriterConfig();

Builder() {}
Expand Down Expand Up @@ -514,9 +514,9 @@ public GrpcStorageOptions.Builder setGrpcInterceptorProvider(
/** @since 2.24.0 This new api is in preview and is subject to breaking changes. */
@BetaApi
public GrpcStorageOptions.Builder setStorageWriterConfig(
@NonNull StorageWriterConfig storageWriterConfig) {
requireNonNull(storageWriterConfig, "storageWriterConfig must be non null");
this.storageWriterConfig = storageWriterConfig;
@NonNull BlobWriteSessionConfig blobWriteSessionConfig) {
requireNonNull(blobWriteSessionConfig, "blobWriteSessionConfig must be non null");
this.blobWriteSessionConfig = blobWriteSessionConfig;
return this;
}

Expand Down Expand Up @@ -584,8 +584,8 @@ public GrpcInterceptorProvider grpcInterceptorProvider() {
return INTERCEPTOR_PROVIDER;
}

public StorageWriterConfig getDefaultStorageWriterConfig() {
return StorageWriterConfigs.getDefault();
public BlobWriteSessionConfig getDefaultStorageWriterConfig() {
return BlobWriteSessionConfigs.getDefault();
}
}

Expand Down Expand Up @@ -638,7 +638,7 @@ public Storage create(StorageOptions options) {
return new GrpcStorageImpl(
grpcStorageOptions,
StorageClient.create(storageSettings),
grpcStorageOptions.storageWriterConfig.createFactory(Clock.systemUTC()),
grpcStorageOptions.blobWriteSessionConfig.createFactory(Clock.systemUTC()),
defaultOpts);
} catch (IOException e) {
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.BlobWriteSession;
import com.google.cloud.storage.BlobWriteSessionConfigs;
import com.google.cloud.storage.BucketInfo;
import com.google.cloud.storage.DataGenerator;
import com.google.cloud.storage.GrpcStorageOptions;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageWriterConfigs;
import com.google.cloud.storage.Storage.BlobWriteOption;
import com.google.cloud.storage.TransportCompatibility.Transport;
import com.google.cloud.storage.it.runner.StorageITRunner;
import com.google.cloud.storage.it.runner.annotations.Backend;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void overrideDefaultBufferSize() throws Exception {
GrpcStorageOptions options =
((GrpcStorageOptions) storage.getOptions())
.toBuilder()
.setStorageWriterConfig(StorageWriterConfigs.getDefault().withChunkSize(256 * 1024))
.setStorageWriterConfig(BlobWriteSessionConfigs.getDefault().withChunkSize(256 * 1024))
.build();
try (Storage s = options.getService()) {
doTest(s);
Expand All @@ -70,7 +71,8 @@ public void overrideDefaultBufferSize() throws Exception {
private void doTest(Storage underTest) throws Exception {
BlobWriteSession sess =
underTest.blobWriteSession(
BlobInfo.newBuilder(bucket, generator.randomObjectName()).build());
BlobInfo.newBuilder(bucket, generator.randomObjectName()).build(),
BlobWriteOption.doesNotExist());

byte[] bytes = DataGenerator.base64Characters().genBytes(512 * 1024);
try (WritableByteChannel w = sess.open()) {
Expand Down

0 comments on commit 7df353b

Please sign in to comment.