Package org.apache.hadoop.fs.s3a.impl
Class UploadContentProviders.BaseContentProvider<T extends InputStream>
java.lang.Object
org.apache.hadoop.fs.s3a.impl.UploadContentProviders.BaseContentProvider<T>
- Type Parameters:
T- type of stream created.
- All Implemented Interfaces:
Closeable,AutoCloseable,software.amazon.awssdk.http.ContentStreamProvider
- Enclosing class:
- UploadContentProviders
@VisibleForTesting
public abstract static class UploadContentProviders.BaseContentProvider<T extends InputStream>
extends Object
implements software.amazon.awssdk.http.ContentStreamProvider, Closeable
Base class for content providers; tracks the number of times a stream
has been opened.
-
Nested Class Summary
Nested classes/interfaces inherited from interface software.amazon.awssdk.http.ContentStreamProvider
software.amazon.awssdk.http.ContentStreamProvider.ProviderType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseContentProvider(long size) Constructor.protectedBaseContentProvider(long size, Supplier<Boolean> isOpen) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the current stream.protected abstract TOverride point for subclasses to create their new streams.protected TCurrent stream.longgetSize()Size as set by constructor parameter.When did this upload start?intHow many times has a stream been created?final InputStreamCreate a new stream.protected TsetCurrentStream(T stream) Set the current stream.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awssdk.http.ContentStreamProvider
name
-
Constructor Details
-
BaseContentProvider
protected BaseContentProvider(long size) Constructor.- Parameters:
size- size of the data. Must be non-negative.
-
BaseContentProvider
Constructor.- Parameters:
size- size of the data. Must be non-negative.isOpen- optional predicate to check if the stream is open.
-
-
Method Details
-
close
public void close()Close the current stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
newStream
Create a new stream.Calls
close()to ensure that any existing stream is closed, thencheckOpen()to verify that the data source is still open. Logs if this is a subsequent event as it implies a failure of the first attempt.- Specified by:
newStreamin interfacesoftware.amazon.awssdk.http.ContentStreamProvider- Returns:
- the new stream
-
createNewStream
Override point for subclasses to create their new streams.- Returns:
- a stream
-
getStreamCreationCount
public int getStreamCreationCount()How many times has a stream been created?- Returns:
- stream creation count
-
getSize
public long getSize()Size as set by constructor parameter.- Returns:
- size of the data
-
getStartTime
When did this upload start?- Returns:
- start time
-
getCurrentStream
Current stream. WhennewStream()is called, this is set to the new value, after closing the previous one.Why? The AWS SDK implementations do this, so there is an implication that it is needed to avoid keeping streams open on retries.
- Returns:
- the current stream, or null if none is open.
-
setCurrentStream
Set the current stream.- Parameters:
stream- the new stream- Returns:
- the current stream.
-
toString
-