use of com.google.cloud.storage.contrib.nio.CloudStorageConfiguration in project gatk by broadinstitute.
the class BucketUtils method getPathOnGcs.
/**
* String -> Path. This *should* not be necessary (use Paths.get(URI.create(...)) instead) , but it currently is
* on Spark because using the fat, shaded jar breaks the registration of the GCS FilesystemProvider.
* To transform other types of string URLs into Paths, use IOUtils.getPath instead.
*/
public static java.nio.file.Path getPathOnGcs(String gcsUrl) {
// use a split limit of -1 to preserve empty split tokens, especially trailing slashes on directory names
final String[] split = gcsUrl.split("/", -1);
final String BUCKET = split[2];
final String pathWithoutBucket = String.join("/", Arrays.copyOfRange(split, 3, split.length));
CloudStorageConfiguration cloudConfig = CloudStorageConfiguration.builder().maxChannelReopens(NIO_MAX_REOPENS).build();
StorageOptions sopt = setGenerousTimeouts(StorageOptions.newBuilder()).build();
return CloudStorageFileSystem.forBucket(BUCKET, cloudConfig, sopt).getPath(pathWithoutBucket);
}
Aggregations