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 theRollingPolicy.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultRollingPolicy.PolicyBuilderA helper class that holds the configuration properties for theDefaultRollingPolicy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DefaultRollingPolicy.PolicyBuilderbuilder()Creates a newDefaultRollingPolicy.PolicyBuilderthat is used to configure and build an instance ofDefaultRollingPolicy.static DefaultRollingPolicy.PolicyBuildercreate()Deprecated.longgetInactivityInterval()Returns time duration of allowed inactivity after which a part file will have to roll.longgetMaxPartSize()Returns the maximum part file size before rolling.longgetRolloverInterval()Returns 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 Detail
-
shouldRollOnCheckpoint
public boolean shouldRollOnCheckpoint(PartFileInfo<BucketID> partFileState) throws IOException
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
public boolean shouldRollOnProcessingTime(PartFileInfo<BucketID> partFileState, long currentTime)
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
public static DefaultRollingPolicy.PolicyBuilder builder()
Creates a newDefaultRollingPolicy.PolicyBuilderthat is used to configure and build an instance ofDefaultRollingPolicy.
-
create
@Deprecated public static DefaultRollingPolicy.PolicyBuilder create()
Deprecated.This method isDeprecated, usebuilder()instead.
-
-