Skip to content

Commit 9009cb1

Browse files
committed
Update setAmazonS3Client
1 parent 28a0241 commit 9009cb1

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,13 +1323,10 @@ public S3Client getAmazonS3V2ClientForTesting(String reason) {
13231323
* Set the client -used in mocking tests to force in a different client.
13241324
* @param client client.
13251325
*/
1326-
protected void setAmazonS3Client(Pair<AmazonS3, S3Client> client) {
1327-
Preconditions.checkNotNull(client.getLeft(), "client");
1328-
Preconditions.checkNotNull(client.getRight(), "clientV2");
1329-
LOG.debug("Setting S3 client to {}", client.getLeft());
1330-
LOG.debug("Setting S3V2 client to {}", client.getRight());
1331-
s3 = client.getLeft();
1332-
s3V2 = client.getRight();
1326+
protected void setAmazonS3Client(S3Client client) {
1327+
Preconditions.checkNotNull(client, "clientV2");
1328+
LOG.debug("Setting S3V2 client to {}", client);
1329+
s3V2 = client;
13331330

13341331
// TODO: still relevant in v2?
13351332
// Need to use a new TransferManager that uses the new client.

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/MockS3AFileSystem.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import java.io.IOException;
2222
import java.net.URI;
2323

24-
import com.amazonaws.AmazonClientException;
25-
import com.amazonaws.services.s3.AmazonS3;
2624
import org.slf4j.Logger;
2725
import org.slf4j.LoggerFactory;
2826

@@ -51,6 +49,7 @@
5149
import org.apache.hadoop.util.Progressable;
5250

5351
import software.amazon.awssdk.core.SdkRequest;
52+
import software.amazon.awssdk.core.exception.SdkException;
5453
import software.amazon.awssdk.services.s3.S3Client;
5554

5655
import static org.apache.hadoop.fs.s3a.audit.AuditTestSupport.noopAuditor;
@@ -205,7 +204,7 @@ public boolean isMagicCommitEnabled() {
205204
* @param client client.
206205
*/
207206
@Override
208-
public void setAmazonS3Client(Pair<AmazonS3, S3Client> client) {
207+
public void setAmazonS3Client(S3Client client) {
209208
LOG.debug("Setting S3 client to {}", client);
210209
super.setAmazonS3Client(client);
211210
}
@@ -348,13 +347,13 @@ public long getDefaultBlockSize() {
348347
void deleteObjectAtPath(Path f,
349348
String key,
350349
boolean isFile)
351-
throws AmazonClientException, IOException {
350+
throws SdkException, IOException {
352351
deleteObject(key);
353352
}
354353

355354
@Override
356355
protected void maybeCreateFakeParentDirectory(Path path)
357-
throws IOException, AmazonClientException {
356+
throws IOException, SdkException {
358357
// no-op
359358
}
360359

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/commit/staging/StagingTestBase.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
import java.util.UUID;
3030
import java.util.stream.Collectors;
3131

32-
import com.amazonaws.services.s3.AmazonS3;
33-
import com.amazonaws.services.s3.AmazonS3Client;
34-
3532
import org.apache.hadoop.util.Lists;
3633
import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
3734
import org.junit.AfterClass;
@@ -342,7 +339,7 @@ public abstract static class JobCommitterTest<C extends OutputCommitter>
342339
// created in Before
343340
private StagingTestBase.ClientResults results = null;
344341
private StagingTestBase.ClientErrors errors = null;
345-
private Pair<AmazonS3, S3Client> mockClient = null;
342+
private S3Client mockClient = null;
346343

347344
@Before
348345
public void setupJob() throws Exception {
@@ -622,9 +619,8 @@ private static<T> T getArgumentAt(InvocationOnMock invocation, int index,
622619
* @param errors when (if any) to fail
623620
* @return the mock client to patch in to a committer/FS instance
624621
*/
625-
public static Pair<AmazonS3, S3Client> newMockS3Client(final ClientResults results,
622+
public static S3Client newMockS3Client(final ClientResults results,
626623
final ClientErrors errors) {
627-
AmazonS3Client mockClient = mock(AmazonS3Client.class);
628624
S3Client mockClientV2 = mock(S3Client.class);
629625
final Object lock = new Object();
630626

@@ -741,8 +737,6 @@ public static Pair<AmazonS3, S3Client> newMockS3Client(final ClientResults resul
741737
.deleteObject(any(DeleteObjectRequest.class));
742738

743739
// to String returns the debug information
744-
when(mockClient.toString()).thenAnswer(
745-
invocation -> "Mock3AClient " + results + " " + errors);
746740
when(mockClientV2.toString()).thenAnswer(
747741
invocation -> "Mock3AClient " + results + " " + errors);
748742

@@ -761,7 +755,7 @@ public static Pair<AmazonS3, S3Client> newMockS3Client(final ClientResults resul
761755
}
762756
});
763757

764-
return Pair.of(mockClient, mockClientV2);
758+
return mockClientV2;
765759
}
766760

767761
/**

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/commit/staging/TestStagingCommitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class TestStagingCommitter extends StagingTestBase.MiniDFSTest {
113113
// created in Before
114114
private StagingTestBase.ClientResults results = null;
115115
private StagingTestBase.ClientErrors errors = null;
116-
private Pair<AmazonS3, S3Client> mockClient = null;
116+
private S3Client mockClient = null;
117117
private File tmpDir;
118118

119119
/**

0 commit comments

Comments
 (0)