IN - The type of input elements.BucketID - The type of ids for the buckets, as returned by the BucketAssigner.@Internal public class Buckets<IN,BucketID> extends Object
StreamingFileSink.
This class is responsible for all bucket-related operations and the actual StreamingFileSink is just plugging in the functionality offered by this class to the lifecycle
of the operator.
| Constructor and Description |
|---|
Buckets(org.apache.flink.core.fs.Path basePath,
org.apache.flink.streaming.api.functions.sink.filesystem.BucketAssigner<IN,BucketID> bucketAssigner,
BucketFactory<IN,BucketID> bucketFactory,
org.apache.flink.streaming.api.functions.sink.filesystem.BucketWriter<IN,BucketID> bucketWriter,
org.apache.flink.streaming.api.functions.sink.filesystem.RollingPolicy<IN,BucketID> rollingPolicy,
int subtaskIndex,
org.apache.flink.streaming.api.functions.sink.filesystem.OutputFileConfig outputFileConfig)
A constructor creating a new empty bucket manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
commitUpToCheckpoint(long checkpointId) |
long |
getMaxPartCounter() |
void |
initializeState(org.apache.flink.api.common.state.ListState<byte[]> bucketStates,
org.apache.flink.api.common.state.ListState<Long> partCounterState)
Initializes the state after recovery from a failure.
|
Bucket<IN,BucketID> |
onElement(IN value,
long currentProcessingTime,
Long elementTimestamp,
long currentWatermark) |
Bucket<IN,BucketID> |
onElement(IN value,
SinkFunction.Context context) |
void |
onProcessingTime(long timestamp) |
void |
setBucketLifeCycleListener(BucketLifeCycleListener<IN,BucketID> bucketLifeCycleListener) |
void |
setFileLifeCycleListener(FileLifeCycleListener<BucketID> fileLifeCycleListener) |
void |
snapshotState(long checkpointId,
org.apache.flink.api.common.state.ListState<byte[]> bucketStatesContainer,
org.apache.flink.api.common.state.ListState<Long> partCounterStateContainer) |
public Buckets(org.apache.flink.core.fs.Path basePath,
org.apache.flink.streaming.api.functions.sink.filesystem.BucketAssigner<IN,BucketID> bucketAssigner,
BucketFactory<IN,BucketID> bucketFactory,
org.apache.flink.streaming.api.functions.sink.filesystem.BucketWriter<IN,BucketID> bucketWriter,
org.apache.flink.streaming.api.functions.sink.filesystem.RollingPolicy<IN,BucketID> rollingPolicy,
int subtaskIndex,
org.apache.flink.streaming.api.functions.sink.filesystem.OutputFileConfig outputFileConfig)
basePath - The base path for our buckets.bucketAssigner - The BucketAssigner provided by the user.bucketFactory - The BucketFactory to be used to create buckets.bucketWriter - The BucketWriter to be used when writing data.rollingPolicy - The RollingPolicy as specified by the user.public void setBucketLifeCycleListener(BucketLifeCycleListener<IN,BucketID> bucketLifeCycleListener)
public void setFileLifeCycleListener(FileLifeCycleListener<BucketID> fileLifeCycleListener)
public void initializeState(org.apache.flink.api.common.state.ListState<byte[]> bucketStates,
org.apache.flink.api.common.state.ListState<Long> partCounterState)
throws Exception
During this process:
bucketStates - the state holding recovered state about active buckets.partCounterState - the state holding the max previously used part counters.Exception - if anything goes wrong during retrieving the state or restoring/committing
of any in-progress/pending part filespublic void commitUpToCheckpoint(long checkpointId)
throws IOException
IOExceptionpublic void snapshotState(long checkpointId,
org.apache.flink.api.common.state.ListState<byte[]> bucketStatesContainer,
org.apache.flink.api.common.state.ListState<Long> partCounterStateContainer)
throws Exception
Exception@VisibleForTesting public Bucket<IN,BucketID> onElement(IN value, SinkFunction.Context context) throws Exception
Exceptionpublic Bucket<IN,BucketID> onElement(IN value, long currentProcessingTime, @Nullable Long elementTimestamp, long currentWatermark) throws Exception
Exceptionpublic void close()
@VisibleForTesting public long getMaxPartCounter()
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.