Skip to content

Commit

Permalink
Removed areInputStreamsDecorated from RemoteTransferContainer
Browse files Browse the repository at this point in the history
Signed-off-by: Raghuvansh Raj <raghraaj@amazon.com>
  • Loading branch information
raghuvanshraj committed Jun 7, 2023
1 parent 240511b commit 1e83814
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class RemoteTransferContainer implements Closeable {
private final long expectedChecksum;
private final OffsetRangeInputStreamSupplier offsetRangeInputStreamSupplier;
private final boolean isRemoteDataIntegritySupported;
private final boolean areInputStreamsDecorated;

private static final Logger log = LogManager.getLogger(RemoteTransferContainer.class);

Expand All @@ -61,7 +60,6 @@ public class RemoteTransferContainer implements Closeable {
* @param offsetRangeInputStreamSupplier A supplier to create OffsetRangeInputStreams
* @param expectedChecksum The expected checksum value for the file being uploaded. This checksum will be used for local or remote data integrity checks
* @param isRemoteDataIntegritySupported A boolean to signify whether the remote repository supports server side data integrity verification
* @param areInputStreamsDecorated A boolean to signify whether the streams created via {@link OffsetRangeInputStreamSupplier#get} are decorated or not
*/
public RemoteTransferContainer(
String fileName,
Expand All @@ -71,8 +69,7 @@ public RemoteTransferContainer(
WritePriority writePriority,
OffsetRangeInputStreamSupplier offsetRangeInputStreamSupplier,
long expectedChecksum,
boolean isRemoteDataIntegritySupported,
boolean areInputStreamsDecorated
boolean isRemoteDataIntegritySupported
) {
this.fileName = fileName;
this.remoteFileName = remoteFileName;
Expand All @@ -82,7 +79,6 @@ public RemoteTransferContainer(
this.offsetRangeInputStreamSupplier = offsetRangeInputStreamSupplier;
this.expectedChecksum = expectedChecksum;
this.isRemoteDataIntegritySupported = isRemoteDataIntegritySupported;
this.areInputStreamsDecorated = areInputStreamsDecorated;
}

/**
Expand Down Expand Up @@ -173,7 +169,7 @@ private LocalStreamSupplier<InputStreamContainer> getMultipartStreamSupplier(
}

private boolean isRemoteDataIntegrityCheckPossible() {
return isRemoteDataIntegritySupported && !areInputStreamsDecorated;
return isRemoteDataIntegritySupported;
}

private void finalizeUpload(boolean uploadSuccessful) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public OffsetRangeInputStream get(long size, long position) throws IOException {
}
},
0,
false,
false
)
) {
Expand All @@ -74,7 +73,6 @@ public OffsetRangeInputStream get(long size, long position) throws IOException {
}
},
0,
false,
false
)
) {
Expand Down Expand Up @@ -129,7 +127,6 @@ public OffsetRangeInputStream get(long size, long position) throws IOException {
}
},
0,
false,
false
)
) {
Expand All @@ -139,13 +136,11 @@ public OffsetRangeInputStream get(long size, long position) throws IOException {
}

public void testTypeOfProvidedStreamsAllCases() throws IOException {
testTypeOfProvidedStreams(true, true);
testTypeOfProvidedStreams(true, false);
testTypeOfProvidedStreams(false, true);
testTypeOfProvidedStreams(false, false);
testTypeOfProvidedStreams(true);
testTypeOfProvidedStreams(false);
}

private void testTypeOfProvidedStreams(boolean isRemoteDataIntegritySupported, boolean areInputStreamsDecorated) throws IOException {
private void testTypeOfProvidedStreams(boolean isRemoteDataIntegritySupported) throws IOException {
try (
RemoteTransferContainer remoteTransferContainer = new RemoteTransferContainer(
testFile.getFileName().toString(),
Expand All @@ -160,13 +155,12 @@ public OffsetRangeInputStream get(long size, long position) throws IOException {
}
},
0,
isRemoteDataIntegritySupported,
areInputStreamsDecorated
isRemoteDataIntegritySupported
)
) {
StreamContext streamContext = remoteTransferContainer.supplyStreamContext(16);
InputStreamContainer inputStreamContainer = streamContext.provideStream(0);
if (shouldOffsetInputStreamsBeChecked(isRemoteDataIntegritySupported, areInputStreamsDecorated)) {
if (shouldOffsetInputStreamsBeChecked(isRemoteDataIntegritySupported)) {
assertTrue(inputStreamContainer.getInputStream() instanceof ResettableCheckedInputStream);
} else {
assertTrue(inputStreamContainer.getInputStream() instanceof OffsetRangeInputStream);
Expand All @@ -175,7 +169,7 @@ public OffsetRangeInputStream get(long size, long position) throws IOException {
}
}

private boolean shouldOffsetInputStreamsBeChecked(boolean isRemoteDataIntegritySupported, boolean areInputStreamsDecorated) {
return !isRemoteDataIntegritySupported || areInputStreamsDecorated;
private boolean shouldOffsetInputStreamsBeChecked(boolean isRemoteDataIntegritySupported) {
return !isRemoteDataIntegritySupported;
}
}

0 comments on commit 1e83814

Please sign in to comment.