Skip to content
Merged
Show file tree
Hide file tree
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 @@ -261,12 +261,18 @@ public boolean shouldRetry(IOException e) {
this.credentials = credentials;
this.maxBytesRewrittenPerCall = null;
this.numRewriteTokensUsed = null;
googleCloudStorageOptions =
GoogleCloudStorageOptions.Builder optionsBuilder =
GoogleCloudStorageOptions.builder()
.setAppName("Beam")
.setReadChannelOptions(gcsReadOptions)
.setGrpcEnabled(shouldUseGrpc)
.build();
.setGrpcEnabled(shouldUseGrpc);
if (storageClient.getRootUrl() != null) {
optionsBuilder.setStorageRootUrl(storageClient.getRootUrl());
}
if (storageClient.getServicePath() != null) {
optionsBuilder.setStorageServicePath(storageClient.getServicePath());
}
googleCloudStorageOptions = optionsBuilder.build();
try {
googleCloudStorage =
createGoogleCloudStorage(googleCloudStorageOptions, storageClient, credentials);
Expand Down Expand Up @@ -495,6 +501,11 @@ private Long toFileSize(StorageObjectOrIOException storageObjectOrIOException)
}
}

@VisibleForTesting
GoogleCloudStorage getGoogleCloudStorage() {
return googleCloudStorage;
}

@VisibleForTesting
void setCloudStorageImpl(GoogleCloudStorage g) {
googleCloudStorage = g;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import com.google.auth.Credentials;
import com.google.cloud.hadoop.gcsio.CreateObjectOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorage;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadOptions;
import com.google.cloud.hadoop.gcsio.StorageResourceId;
Expand Down Expand Up @@ -1866,6 +1867,18 @@ public void testReadMetricsAreNotCollectedWhenNotEnabledOpenWithOptions() throws
testReadMetrics(false, GoogleCloudStorageReadOptions.DEFAULT);
}

@Test
public void testGcsEndpoint() throws IOException {
GcsOptions pipelineOptions = PipelineOptionsFactory.as(GcsOptions.class);
pipelineOptions.setGcsEndpoint("http://localhost:4443/storage/v1/");

GcsUtil gcsUtil = pipelineOptions.getGcsUtil();
GoogleCloudStorageImpl gcsImpl =
(GoogleCloudStorageImpl) gcsUtil.delegate.getGoogleCloudStorage();
assertEquals("http://localhost:4443/", gcsImpl.getOptions().getStorageRootUrl());
assertEquals("storage/v1/", gcsImpl.getOptions().getStorageServicePath());
}

/** A helper to wrap a {@link GenericJson} object in a content stream. */
private static InputStream toStream(String content) throws IOException {
return new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
Expand Down
Loading