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(Path basePath,
BucketAssigner<IN,BucketID> bucketAssigner,
BucketFactory<IN,BucketID> bucketFactory,
BucketWriter<IN,BucketID> bucketWriter,
RollingPolicy<IN,BucketID> rollingPolicy,
int subtaskIndex,
OutputFileConfig outputFileConfig)
A constructor creating a new empty bucket manager.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
closePartFileForBucket(BucketID bucketID) |
void |
commitUpToCheckpoint(long checkpointId) |
long |
getMaxPartCounter() |
void |
initializeState(ListState<byte[]> bucketStates,
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,
ListState<byte[]> bucketStatesContainer,
ListState<Long> partCounterStateContainer) |
public Buckets(Path basePath, BucketAssigner<IN,BucketID> bucketAssigner, BucketFactory<IN,BucketID> bucketFactory, BucketWriter<IN,BucketID> bucketWriter, RollingPolicy<IN,BucketID> rollingPolicy, int subtaskIndex, 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(ListState<byte[]> bucketStates, 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
IOException
public void snapshotState(long checkpointId, ListState<byte[]> bucketStatesContainer, ListState<Long> partCounterStateContainer) throws Exception
Exception
@VisibleForTesting public Bucket<IN,BucketID> onElement(IN value, SinkFunction.Context context) throws Exception
Exception
public Bucket<IN,BucketID> onElement(IN value, long currentProcessingTime, @Nullable Long elementTimestamp, long currentWatermark) throws Exception
Exception
public void closePartFileForBucket(BucketID bucketID) throws Exception
Exception
public void close()
@VisibleForTesting public long getMaxPartCounter()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.