Skip to content

Commit 47c0c38

Browse files
committed
Addressing code review comments
1 parent c5b5550 commit 47c0c38

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/FileSystemHelperImpl.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,32 +77,35 @@ public ObjectStorageSpaceVerificationResult objectsFromBucketWillFitInDirectory(
7777

7878
long requiredSpace = 0;
7979
long availableSpace = 0;
80-
final IOException ioException = null;
8180

8281
if ( ! pathObjectExists(destinationDirectory)) {
82+
final IOException ioException = null;
8383
return new ObjectStorageSpaceVerificationResult(ObjectStorageSpaceVerificationResult.VerificationStatus.PathDoesNotExist,
8484
requiredSpace, availableSpace, ioException);
8585
}
8686

8787
if ( ! pathIsDirectory(destinationDirectory)) {
88+
final IOException ioException = null;
8889
return new ObjectStorageSpaceVerificationResult(ObjectStorageSpaceVerificationResult.VerificationStatus.PathIsNotADirectory,
8990
requiredSpace, availableSpace, ioException);
9091
}
9192

9293
if ( ! pathIsWritable(destinationDirectory)) {
94+
final IOException ioException = null;
9395
return new ObjectStorageSpaceVerificationResult(ObjectStorageSpaceVerificationResult.VerificationStatus.PathLacksAccess,
9496
requiredSpace, availableSpace, ioException);
9597
}
9698

9799
try {
98100
helpers.ensureBucketExists(bucketName);
99101
} catch (final IOException e) {
102+
final IOException ioException = null;
100103
return new ObjectStorageSpaceVerificationResult(ObjectStorageSpaceVerificationResult.VerificationStatus.BucketDoesNotExist,
101104
requiredSpace, availableSpace, ioException);
102105
}
103106

104107
try {
105-
requiredSpace = getRequiredSpaceForObjects(getObjectSizes(helpers, bucketName, objectNames));
108+
requiredSpace = getRequiredSpaceForObjects(helpers, bucketName, objectNames);
106109
availableSpace = getAvailableFileSpace(destinationDirectory);
107110
} catch (final IOException e) {
108111
return new ObjectStorageSpaceVerificationResult(ObjectStorageSpaceVerificationResult.VerificationStatus.CaughtIOException,
@@ -112,14 +115,17 @@ public ObjectStorageSpaceVerificationResult objectsFromBucketWillFitInDirectory(
112115
final ObjectStorageSpaceVerificationResult.VerificationStatus verificationStatus = availableSpace > requiredSpace ?
113116
ObjectStorageSpaceVerificationResult.VerificationStatus.OK : ObjectStorageSpaceVerificationResult.VerificationStatus.PathLacksSufficientStorageSpace;
114117

118+
final IOException ioException = null;
115119
return new ObjectStorageSpaceVerificationResult(verificationStatus, requiredSpace, availableSpace, ioException);
116120
}
117121

118-
private Map<String, Long> getObjectSizes(final Ds3ClientHelpers helpers,
119-
final String bucketName,
120-
final Collection<String> objectNames)
121-
throws IOException
122+
private long getRequiredSpaceForObjects(final Ds3ClientHelpers helpers,
123+
final String bucketName,
124+
final Collection<String> objectNames)
125+
throws IOException
122126
{
127+
long result = 0;
128+
123129
final Map<String, Long> objectSizeMap = new HashMap<>();
124130

125131
final Iterable<Contents> bucketContents = helpers.listObjects(bucketName);
@@ -128,14 +134,9 @@ private Map<String, Long> getObjectSizes(final Ds3ClientHelpers helpers,
128134
objectSizeMap.put(bucketContent.getKey(), bucketContent.getSize());
129135
}
130136

137+
// Of the objects in the bucket, keep the information about only those in objectNames
131138
objectSizeMap.keySet().retainAll(objectNames);
132139

133-
return objectSizeMap;
134-
}
135-
136-
private long getRequiredSpaceForObjects(final Map<String, Long> objectSizeMap) {
137-
long result = 0;
138-
139140
for (final long objectSize : objectSizeMap.values()) {
140141
result += objectSize;
141142
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/UnrecoverableIOException.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717

1818
import java.io.IOException;
1919

20+
/**
21+
* An UnrecoverableIOException is used to classify IOExceptions into one of 2 types:
22+
* those that should result in retrying a data transfer, such as a failure in an HTTP GET or PUT;
23+
* and those that should <b>not</b> result in retrying a data transfer, such as a failure writing to
24+
* or reading from a file. During an HTTP PUT or GET that involves transferring data to or from
25+
* a file, file system failures are considered non-recoverable, where network-related failures
26+
* are considered recoverable.
27+
*/
2028
public class UnrecoverableIOException extends IOException {
2129
public UnrecoverableIOException() {
2230
super();

0 commit comments

Comments
 (0)