APISonar


io.pravega.controller.stream.api.grpc.v1.Controller.RetentionPolicy.RetentionPolicyType.TIME

> io > pravega > controller > stream > api > grpc > v1 > Controller > RetentionPolicy > RetentionPolicyType > TIME
io APIs pravega APIs controller APIs stream APIs api APIs grpc APIs v1 APIs Controller APIs RetentionPolicy APIs RetentionPolicyType APIs TIME APIs

Example 1
public void decodeRetentionPolicy() {
        Controller.RetentionPolicy policy1 = ModelHelper.decode(RetentionPolicy.bySizeBytes(1000L));
        assertEquals(Controller.RetentionPolicy.RetentionPolicyType.SIZE, policy1.getRetentionType());
        assertEquals(1000L, policy1.getRetentionParam());

        Controller.RetentionPolicy policy2 = ModelHelper.decode(RetentionPolicy.byTime(Duration.ofDays(100L)));
        assertEquals(Controller.RetentionPolicy.RetentionPolicyType.TIME, policy2.getRetentionType());
        assertEquals(Duration.ofDays(100L).toMillis(), policy2.getRetentionParam());

        Controller.RetentionPolicy policy3 = ModelHelper.decode((RetentionPolicy) null);
        assertNull(policy3);
    }
Example 2
public void decodeStreamConfig() {
        StreamConfig config = ModelHelper.decode("scope", "test", StreamConfiguration.builder()
                .scalingPolicy(ScalingPolicy.byEventRate(100, 2, 3))
                .retentionPolicy(RetentionPolicy.byTime(Duration.ofDays(100L)))
                .build());
        assertEquals("test", config.getStreamInfo().getStream());
        Controller.ScalingPolicy policy = config.getScalingPolicy();
        assertEquals(Controller.ScalingPolicy.ScalingPolicyType.BY_RATE_IN_EVENTS_PER_SEC, policy.getScaleType());
        assertEquals(100L, policy.getTargetRate());
        assertEquals(2, policy.getScaleFactor());
        assertEquals(3, policy.getMinNumSegments());
        Controller.RetentionPolicy retentionPolicy = config.getRetentionPolicy();
        assertEquals(Controller.RetentionPolicy.RetentionPolicyType.TIME, retentionPolicy.getRetentionType());
        assertEquals(Duration.ofDays(100L).toMillis(), retentionPolicy.getRetentionParam());
    }