Skip to content

Commit fd9516a

Browse files
committed
HADOOP-19654. SDK upgrade
- Lots of qualifying s3 express incomplete uploads - cloudstore listobjects working again (no tests! who knew!)
1 parent fe9a7a9 commit fd9516a

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

src/main/java/org/apache/hadoop/fs/s3a/sdk/ListObjects.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public ListObjects() {
7676

7777
@Override
7878
public int run(String[] args) throws Exception {
79-
List<String> paths = processArgs(args, 2, -1, USAGE);
79+
List<String> paths = processArgs(args, 1, 1, USAGE);
8080

8181
final Configuration conf = createPreconfiguredConfig();
8282
// stop auditing rejecting client direct calls.
@@ -106,6 +106,9 @@ public int run(String[] args) throws Exception {
106106
String bucket = fs.getBucket();
107107
final S3Client s3 = fs.getS3AInternals().getAmazonS3Client("listobjects");
108108
String key = S3ListingSupport.pathToKey(source);
109+
if (!key.endsWith("/")) {
110+
key += "/";
111+
}
109112
ListObjectsV2Request request = S3ListingSupport.createListObjectsRequest(
110113
source.toUri().getHost(), key, null);
111114

@@ -116,7 +119,7 @@ public int run(String[] args) throws Exception {
116119
List<ObjectIdentifier> objectsToDelete =
117120
new ArrayList<>(deletePageSize);
118121

119-
heading("Listing objects under %s", source);
122+
heading("Listing Objects under %s", source);
120123
boolean finished = false;
121124
while (!finished && objects.hasNext()) {
122125
final ListObjectsV2Response page = objects.next();
@@ -168,16 +171,14 @@ public int run(String[] args) throws Exception {
168171
String action = delete ? "Deleted" : "Found";
169172
println("%s %d objects with total size %d bytes", action, objectCount, size);
170173
if (!prefixes.isEmpty()) {
171-
println("");
172174
heading("%s prefixes", prefixes.size());
173175
for (String prefix : prefixes) {
174176
println(prefix);
175177
}
176178
}
177179
if (!markers.isEmpty()) {
178-
println("");
179180
int markerCount = markers.size();
180-
heading("marker count: %d", markerCount);
181+
heading("Marker count: %d", markerCount);
181182
if (purge) {
182183
println("Purging all directory markers");
183184
}

src/main/java/org/apache/hadoop/fs/s3a/sdk/S3ListingSupport.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
package org.apache.hadoop.fs.s3a.sdk;
2020

21-
import java.text.DateFormat;
22-
import java.text.SimpleDateFormat;
23-
2421
import org.slf4j.Logger;
2522
import org.slf4j.LoggerFactory;
2623
import software.amazon.awssdk.services.s3.model.ListObjectVersionsRequest;
@@ -39,8 +36,6 @@ public class S3ListingSupport {
3936

4037
private static final Logger LOG = LoggerFactory.getLogger(S3ListingSupport.class);
4138

42-
private static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
43-
4439
public static final int MAX_KEYS = 5000;
4540

4641
/**
@@ -134,16 +129,14 @@ public static boolean objectRepresentsDirectory(final String name,
134129
public static String stringify(S3Object summary) {
135130
return String.format("\"%s\"\tsize: [%d]\t%s\ttag: %s", summary.key(),
136131
summary.size(),
137-
df.format(summary.lastModified()),
132+
summary.lastModified().toString(),
138133
summary.eTag());
139134
}
140135

141136
static boolean isDirMarker(final ObjectVersion summary) {
142137
return objectRepresentsDirectory(summary.key(), summary.size());
143138
}
144139

145-
146-
147140
static int result(boolean b) {
148141
return b ? 1 : 0;
149142
}

0 commit comments

Comments
 (0)