Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: protected *and* deprecated methods #231

Merged
merged 5 commits into from
Oct 26, 2023
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repositories {

group = 'software.amazon.nio.s3'
archivesBaseName = 'nio-spi-for-s3'
version = '1.2.5-dev'
version = '2.0.0-dev'

apply plugin: 'java'
sourceCompatibility = 1.8
Expand Down
83 changes: 0 additions & 83 deletions src/main/java/software/amazon/nio/spi/s3/S3FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,89 +66,6 @@ protected S3FileSystem(S3FileSystemProvider provider, S3NioSpiConfiguration conf
this.provider = provider;
}


/**
* Create a filesystem that represents the bucket specified by the URI
*
* @param uriString a valid S3 URI to a bucket, e.g "{@code s3://mybucket}"
* @param provider the provider to be used with this fileSystem
*
* @deprecated the preferred way to create a file system is to use NIO or
* the provider itself:
*
* {@code Path p = Paths.get("s3://mybucket");}
*
* This method should be replaced with {@code new S3FileSystem(provider, config)}
*
*/
@Deprecated
protected S3FileSystem(String uriString, S3FileSystemProvider provider){
this(URI.create(uriString), provider, null );
}

/**
* Create a filesystem that represents the bucket specified by the URI
*
* @param uri a valid S3 URI to a bucket, e.g {@code URI.create("s3://mybucket")}
* @param provider the provider to be used with this fileSystem
*
* @deprecated the preferred way to create a file system is to use NIO or
* the provider itself:
*
* {@code Path p = Paths.get("s3://mybucket");}
*
* This method should be replaced with {@code new S3FileSystem(provider)}
*/
@Deprecated
protected S3FileSystem(URI uri, S3FileSystemProvider provider) {
this(uri, provider, null);

}

/**
* Create a filesystem that represents the bucket specified by the URI
*
* @param uri a valid S3 URI to a bucket, e.g <code>URI.create("s3://mybucket")</code>
* @param provider the provider to be used with this fileSystem
* @param config the configuration to use; can be null to use a default configuration
*
* @deprecated the preferred way to create a file system is to use NIO or
* the provider itself:
*
* {@code Path p = Paths.get("s3://mybucket");}
*
* This method should be replaced with {@code new S3FileSystem(provider, config)}
*/
@Deprecated
protected S3FileSystem(URI uri, S3FileSystemProvider provider, S3NioSpiConfiguration config) {
this(provider, config);

//
// note that this is pretty bad: we are picking some loginc from the
// provider and we patch it here...
//
S3FileSystemInfo info = provider.fileSystemInfo(uri);
configuration.withBucketName(info.bucket());
}

/**
* Create a filesystem that represents the named bucket with minimal
* configuration. This should be used for testing purposes only.
*
* @param bucketName the name of the bucket. Must not be null or empty
*
* @deprecated the preferred way to create a file system is to use NIO or
* the provider itself:
*
* {@code Path p = Paths.get("s3://mybucket");}
*
* This method should be replaced with {@code new S3FileSystem(provider, config)}
*/
@Deprecated
protected S3FileSystem(String bucketName){
this (new S3FileSystemProvider(), new S3NioSpiConfiguration().withBucketName(bucketName));
}

/**
* Returns the provider that created this file system.
*
Expand Down
226 changes: 0 additions & 226 deletions src/main/java/software/amazon/nio/spi/s3/S3FileSystemProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,56 +331,6 @@ public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> o
return channel;
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path path = ...;
* S3AsyncClient s3 = ...;
* Set&lt;OpenOption&gt; options = ...;
*
* p.newByteChannel(s3, path, options);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path path = ...;
*
* p.newByteChannel(path, filter);
* </pre>
*/
@Deprecated
protected SeekableByteChannel newByteChannel(S3AsyncClient client, Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
return this.newByteChannel(null, path, options, attrs);
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path dir = ...;
* S3AsyncClient s3 = ...;
* DirectoryStream filter = ...;
*
* p.newDirectoryStream(s3, path, filter);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path dir = ...;
*
* p.newDirectoryStreampath, filter);
* </pre>
*/
@Deprecated
protected DirectoryStream<Path> newDirectoryStream(S3AsyncClient s3Client, Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException, ExecutionException, InterruptedException {
return newDirectoryStream(dir, filter);
}

/**
* Opens a directory, returning a {@code DirectoryStream} to iterate over
* the entries in the directory. This method works in exactly the manner
Expand Down Expand Up @@ -510,30 +460,6 @@ public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOExcept
}
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path dir = ...;
* S3AsyncClient s3 = ...;
*
* p.createDirectory(s3, dir);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path dir = ...;
*
* p.createDirectory(source, target);
* </pre>
*/
@Deprecated
protected void createDirectory(S3AsyncClient s3Client, Path dir, FileAttribute<?>... attrs) throws IOException, ExecutionException, InterruptedException {
createDirectory(forceAwsClient(dir, s3Client), attrs);
}

/**
* Deletes a file. This method works in exactly the manner specified by the
* {@link Files#delete} method.
Expand Down Expand Up @@ -575,32 +501,6 @@ public void delete(Path path) throws IOException {
}
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path path = ...;
* S3AsyncClient s3 = ...;
*
* p.delete(s3, path);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path path = ...;
*
* p.delete(path);
* </pre>
*/
@Deprecated
protected void delete(S3AsyncClient s3Client, Path path) throws IOException, ExecutionException, InterruptedException {
delete(forceAwsClient(path, s3Client));
}



/**
* Copy a file to a target file. This method works in exactly the manner
* specified by the {@link Files#copy(Path, Path, CopyOption[])} method
Expand Down Expand Up @@ -672,30 +572,6 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep
}
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path source = ..., target = ,,,;
* S3AsyncClient s3 = ...;
*
* p.copy(s3, source, target);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path source = ..., target = ,,,;
*
* p.copy(source, target);
* </pre>
*/
@Deprecated
protected void copy(S3AsyncClient s3Client, Path source, Path target, CopyOption... options) throws IOException, ExecutionException, InterruptedException {
copy(forceAwsClient(source, s3Client), target, options);
}

protected boolean exists(S3AsyncClient s3Client, S3Path path) throws InterruptedException, TimeoutException {
try {
s3Client.headObject(HeadObjectRequest.builder().bucket(path.bucketName()).key(path.getKey()).build())
Expand All @@ -722,30 +598,6 @@ public void move(Path source, Path target, CopyOption... options) throws IOExcep
this.delete(source);
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path source = ..., target = ,,,;
* S3AsyncClient s3 = ...;
*
* p.move(s3, source, target);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path source = ..., target = ,,,;
*
* p.move(source, target);
* </pre>
*/
@Deprecated
protected void move(S3AsyncClient s3Client, Path source, Path target, CopyOption... options) throws IOException, ExecutionException, InterruptedException {
move(forceAwsClient(source, s3Client), target, options);
}

/**
* Tests if two paths locate the same file. This method works in exactly the
* manner specified by the {@link Files#isSameFile} method.
Expand Down Expand Up @@ -903,30 +755,6 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException {
}
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path path = ...;
* S3AsyncClient s3 = ...;
*
* p.checkAccess(s3, dir);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path path = ...;
*
* p.checkAccess(path);
* </pre>
*/
@Deprecated
protected void checkAccess(S3AsyncClient s3Client, Path path, AccessMode... modes) throws IOException, ExecutionException, InterruptedException {
checkAccess(forceAwsClient(path, s3Client), modes);
}

/**
* Returns a file attribute view of a given type. This method works in
* exactly the manner specified by the {@link Files#getFileAttributeView}
Expand Down Expand Up @@ -979,30 +807,6 @@ public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type
}
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path path = ...;
* S3AsyncClient s3 = ...;
*
* p.readAttributes(s3, dir, type);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path path = ...;
*
* p.readAttributes(path, type);
* </pre>
*/
@Deprecated
protected <A extends BasicFileAttributes> A readAttributes(S3AsyncClient s3AsyncClient, Path path, Class<A> type, LinkOption... options) {
return readAttributes(forceAwsClient(path, s3AsyncClient), type, options);
}

/**
* Reads a set of file attributes as a bulk operation. Largely equivalent to {@code readAttributes(Path path, Class<A> type, LinkOption... options)}
* where the returned object is a map of method names (attributes) to values, filtered on the comma separated {@code attributes}.
Expand Down Expand Up @@ -1042,30 +846,6 @@ public Map<String, Object> readAttributes(Path path, String attributes, LinkOpti
.asMap(attrSet::contains);
}

/**
*
* @deprecated in favour of using a proper S3ClientProvider in S3FileSystem.
* For instance, instead of the following code:
* <pre>
* S3FileSystemProvider p = ...;
* S3Path path = ...;
* S3AsyncClient s3 = ...;
*
* p.readAttributes(s3, dir, attributes);
* </pre>
* something equivalent to the below should be used:
* <pre>
* S3FileSystemProvider p = new MyFileSystemProvider(new MyClientProvider());
* S3Path path = ...;
*
* p.readAttributes(path, attributes);
* </pre>
*/
@Deprecated
protected void readAttributes(S3AsyncClient client, Path path, String attributes, LinkOption... options) {
readAttributes(forceAwsClient(path, client), attributes, options);
}

/**
* File attributes of S3 objects cannot be set other than by creating a new object
*
Expand Down Expand Up @@ -1128,12 +908,6 @@ private static List<List<ObjectIdentifier>> getContainedObjectBatches(S3AsyncCli
return keys;
}

private S3Path forceAwsClient(final Path path, final S3AsyncClient client) {
S3Path p = (S3Path)path;
p.getFileSystem().clientProvider(new FixedS3ClientProvider(client));
return p;
}

protected static S3Path checkPath(Path obj) {
Objects.requireNonNull(obj);
if (!(obj instanceof S3Path))
Expand Down
Loading