Package io.pravega.client.stream
Class ScalingPolicy
- java.lang.Object
-
- io.pravega.client.stream.ScalingPolicy
-
- All Implemented Interfaces:
java.io.Serializable
public class ScalingPolicy extends java.lang.Object implements java.io.Serializable
A policy that specifies how the number of segments in a stream should scale over time.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ScalingPolicy.ScaleType
static class
ScalingPolicy.ScalingPolicyBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ScalingPolicy.ScalingPolicyBuilder
builder()
static ScalingPolicy
byDataRate(int targetKBps, int scaleFactor, int minNumSegments)
Create a scaling policy to configure a stream to scale up and down according to byte rate.static ScalingPolicy
byEventRate(int targetRate, int scaleFactor, int minNumSegments)
Create a scaling policy to configure a stream to scale up and down according to event rate.protected boolean
canEqual(java.lang.Object other)
boolean
equals(java.lang.Object o)
static ScalingPolicy
fixed(int numSegments)
Create a scaling policy to configure a stream to have a fixed number of segments.int
getMinNumSegments()
int
getScaleFactor()
ScalingPolicy.ScaleType
getScaleType()
int
getTargetRate()
int
hashCode()
java.lang.String
toString()
-
-
-
Method Detail
-
fixed
public static ScalingPolicy fixed(int numSegments)
Create a scaling policy to configure a stream to have a fixed number of segments.- Parameters:
numSegments
- Fixed number of segments for the stream.- Returns:
- Scaling policy object.
-
byEventRate
public static ScalingPolicy byEventRate(int targetRate, int scaleFactor, int minNumSegments)
Create a scaling policy to configure a stream to scale up and down according to event rate. Pravega scales a stream segment up in the case that one of these conditions holds: - The two-minute rate is greater than 5x the target rate - The five-minute rate is greater than 2x the target rate - The ten-minute rate is greater than the target rate It scales a segment down (merges with a neighbor segment) in the case that both these conditions hold: - The two-, five-, ten-minute rate is smaller than the target rate - The twenty-minute rate is smaller than half of the target rate We additionally consider a cool-down period during which the segment is not considered for scaling. This period is determined by the configuration parameter autoScale.cooldownInSeconds; the default value is 10 minutes. The scale factor bounds the number of new segments that can be created upon a scaling event. In the case the controller computes the number of splits to be greater than the scale factor for a given scale-up event, the number of splits for the event is going to be equal to the scale factor. The policy is configured with a minimum number of segments for the stream, independent of the number of scale down events.- Parameters:
targetRate
- Target rate in events per second to enable scaling events per segment.scaleFactor
- Maximum number of splits of a segment for a scale-up event.minNumSegments
- Minimum number of segments that a stream can have independent of the number of scale down events.- Returns:
- Scaling policy object.
-
byDataRate
public static ScalingPolicy byDataRate(int targetKBps, int scaleFactor, int minNumSegments)
Create a scaling policy to configure a stream to scale up and down according to byte rate. Pravega scales a stream segment up in the case that one of these conditions holds: - The two-minute rate is greater than 5x the target rate - The five-minute rate is greater than 2x the target rate - The ten-minute rate is greater than the target rate It scales a segment down (merges with a neighbor segment) in the case that both these conditions hold: - The two-, five-, ten-minute rate is smaller than the target rate - The twenty-minute rate is smaller than half of the target rate We additionally consider a cool-down period during which the segment is not considered for scaling. This period is determined by the configuration parameter autoScale.cooldownInSeconds; the default value is 10 minutes. The scale factor bounds the number of new segments that can be created upon a scaling event. In the case the controller computes the number of splits to be greater than the scale factor for a given scale-up event, the number of splits for the event is going to be equal to the scale factor. The policy is configured with a minimum number of segments for a stream, independent of the number of scale down events.- Parameters:
targetKBps
- Target rate in kilo bytes per second to enable scaling events per segment.scaleFactor
- Maximum number of splits of a segment for a scale-up event.minNumSegments
- Minimum number of segments that a stream can have independent of the number of scale down events.- Returns:
- Scaling policy object.
-
builder
public static ScalingPolicy.ScalingPolicyBuilder builder()
-
getScaleType
public ScalingPolicy.ScaleType getScaleType()
-
getTargetRate
public int getTargetRate()
-
getScaleFactor
public int getScaleFactor()
-
getMinNumSegments
public int getMinNumSegments()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-