Skip to content

Commit

Permalink
remove use of S3ClientStore
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanthorpe committed Jul 18, 2024
1 parent 83ca277 commit cc8cb1d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public S3Client getS3Client(URI uri, Properties props) {
.httpClient(httpClient)
.serviceConfiguration(s3Configuration)
.overrideConfiguration(clientOverrideConfiguration)
.crossRegionAccessEnabled(true)
.region(region);


Expand Down
23 changes: 7 additions & 16 deletions filesystems/s3/src/main/java/org/lerch/s3fs/S3FileStore.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package org.lerch.s3fs;

import org.lerch.s3fs.util.S3ClientStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3Configuration;
import software.amazon.awssdk.services.s3.model.*;
import software.amazon.awssdk.services.s3.model.Bucket;
import software.amazon.awssdk.services.s3.model.GetBucketAclRequest;
import software.amazon.awssdk.services.s3.model.HeadBucketRequest;
import software.amazon.awssdk.services.s3.model.ListBucketsRequest;
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
import software.amazon.awssdk.services.s3.model.Owner;

import java.io.IOException;
import java.net.URI;
import java.nio.file.FileStore;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.FileStoreAttributeView;
Expand All @@ -24,14 +23,11 @@ public class S3FileStore extends FileStore implements Comparable<S3FileStore> {

private S3FileSystem fileSystem;
private String name;
private S3Client defaultClient;
private final Logger logger = LoggerFactory.getLogger("S3FileStore");

public S3FileStore(S3FileSystem s3FileSystem, String name) {
this.fileSystem = s3FileSystem;
this.name = name;
// the default client can be used for getBucketLocation operations
this.defaultClient = S3Client.builder().endpointOverride(URI.create("https://s3.us-east-1.amazonaws.com")).region(Region.US_EAST_1).build();
}

@Override
Expand Down Expand Up @@ -127,13 +123,8 @@ public S3Path getRootDirectory() {
return new S3Path(fileSystem, "/" + this.name());
}

/**
* Gets a client suitable for this FileStore (bucket) including configuring the correct region endpoint. If no client
* exists one will be constructed and cached.
* @return a client
*/
public S3Client getClient() {
return S3ClientStore.getInstance().getClientForBucketName(this.name);
return fileSystem.getClient();
}

public Owner getOwner() {
Expand Down
18 changes: 8 additions & 10 deletions filesystems/s3/src/main/java/org/lerch/s3fs/S3FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class S3FileSystem extends FileSystem implements Comparable<S3FileSystem>
private final String key;
private final S3Client client;
private final String endpoint;
private int cache;
private final int cache;

public S3FileSystem(S3FileSystemProvider provider, String key, S3Client client, String endpoint) {
this.provider = provider;
Expand Down Expand Up @@ -109,15 +109,13 @@ public WatchService newWatchService() throws IOException {
throw new UnsupportedOperationException();
}

// /**
// * Deprecated: since SDKv2 many S3 operations need to be signed with a client using the same Region as the location
// * of the bucket. Prefer S3Path.client() instead.
// * @return
// */
// @Deprecated
// public S3Client getClient() {
// return client;
// }
/**
* get the client associated with this fileSystem.
* @return S3Client
*/
public S3Client getClient() {
return client;
}

/**
* get the endpoint associated with this fileSystem.
Expand Down
100 changes: 0 additions & 100 deletions filesystems/s3/src/main/java/org/lerch/s3fs/util/S3ClientStore.java

This file was deleted.

2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Dependencies {
private val akkaV = "2.5.32" // scala-steward:off (CROM-6637)
private val ammoniteOpsV = "2.4.1"
private val apacheHttpClientV = "4.5.13"
private val awsSdkV = "2.17.265"
private val awsSdkV = "2.26.19"
// We would like to use the BOM to manage Azure SDK versions, but SBT doesn't support it.
// https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/boms/azure-sdk-bom
// https://github.com/sbt/sbt/issues/4531
Expand Down

0 comments on commit cc8cb1d

Please sign in to comment.