Class DefaultRollingPolicy<IN,BucketID>
java.lang.Object
org.apache.flink.streaming.api.functions.sink.filesystem.rollingpolicies.DefaultRollingPolicy<IN,BucketID>
- All Implemented Interfaces:
Serializable,RollingPolicy<IN,BucketID>
@PublicEvolving
public final class DefaultRollingPolicy<IN,BucketID>
extends Object
implements RollingPolicy<IN,BucketID>
The default implementation of the
RollingPolicy.
This policy rolls a part file if:
- there is no open part file,
- the current file has reached the maximum bucket size (by default 128MB),
- the current file is older than the roll over interval (by default 60 sec), or
- the current file has not been written to for more than the allowed inactivityTime (by default 60 sec).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA helper class that holds the configuration properties for theDefaultRollingPolicy. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a newDefaultRollingPolicy.PolicyBuilderthat is used to configure and build an instance ofDefaultRollingPolicy.create()Deprecated.longReturns time duration of allowed inactivity after which a part file will have to roll.longReturns the maximum part file size before rolling.longReturns the maximum time duration a part file can stay open before rolling.booleanshouldRollOnCheckpoint(PartFileInfo<BucketID> partFileState) Determines if the in-progress part file for a bucket should roll on every checkpoint.booleanshouldRollOnEvent(PartFileInfo<BucketID> partFileState, IN element) Determines if the in-progress part file for a bucket should roll based on its current state, e.g. its size.booleanshouldRollOnProcessingTime(PartFileInfo<BucketID> partFileState, long currentTime) Determines if the in-progress part file for a bucket should roll based on a time condition.
-
Method Details
-
shouldRollOnCheckpoint
Description copied from interface:RollingPolicyDetermines if the in-progress part file for a bucket should roll on every checkpoint.- Specified by:
shouldRollOnCheckpointin interfaceRollingPolicy<IN,BucketID> - Parameters:
partFileState- the state of the currently open part file of the bucket.- Returns:
Trueif the part file should roll, {@link false} otherwise.- Throws:
IOException
-
shouldRollOnEvent
public boolean shouldRollOnEvent(PartFileInfo<BucketID> partFileState, IN element) throws IOException Description copied from interface:RollingPolicyDetermines if the in-progress part file for a bucket should roll based on its current state, e.g. its size.- Specified by:
shouldRollOnEventin interfaceRollingPolicy<IN,BucketID> - Parameters:
partFileState- the state of the currently open part file of the bucket.element- the element being processed.- Returns:
Trueif the part file should roll, {@link false} otherwise.- Throws:
IOException
-
shouldRollOnProcessingTime
Description copied from interface:RollingPolicyDetermines if the in-progress part file for a bucket should roll based on a time condition.- Specified by:
shouldRollOnProcessingTimein interfaceRollingPolicy<IN,BucketID> - Parameters:
partFileState- the state of the currently open part file of the bucket.currentTime- the current processing time.- Returns:
Trueif the part file should roll, {@link false} otherwise.
-
getMaxPartSize
public long getMaxPartSize()Returns the maximum part file size before rolling.- Returns:
- Max size in bytes
-
getRolloverInterval
public long getRolloverInterval()Returns the maximum time duration a part file can stay open before rolling.- Returns:
- Time duration in milliseconds
-
getInactivityInterval
public long getInactivityInterval()Returns time duration of allowed inactivity after which a part file will have to roll.- Returns:
- Time duration in milliseconds
-
builder
Creates a newDefaultRollingPolicy.PolicyBuilderthat is used to configure and build an instance ofDefaultRollingPolicy. -
create
Deprecated.This method isDeprecated, usebuilder()instead.
-