StreamConfiguration streamConfiguration = ModelHelper.getUpdateStreamConfig( updateStreamRequest); controllerService.updateStream(scopeName, streamName, streamConfiguration).thenApply(streamStatus -> { log.info("Successfully updated stream config for: {}/{}", scopeName, streamName); return Response.status(Status.OK) .entity(ModelHelper.encodeStreamResponse(scopeName, streamName, streamConfiguration)).build(); } else if (streamStatus.getStatus() == UpdateStreamStatus.Status.STREAM_NOT_FOUND || streamStatus.getStatus() == UpdateStreamStatus.Status.SCOPE_NOT_FOUND) {
StreamConfiguration streamConfiguration = ModelHelper.getCreateStreamConfig(createStreamRequest); controllerService.createStream(scopeName, streamName, streamConfiguration, System.currentTimeMillis()) .thenApply(streamStatus -> { log.info("Successfully created stream: {}/{}", scopeName, streamName); resp = Response.status(Status.CREATED). entity(ModelHelper.encodeStreamResponse(scopeName, streamName, streamConfiguration)).build(); } else if (streamStatus.getStatus() == CreateStreamStatus.Status.STREAM_EXISTS) { log.warn("Stream already exists: {}/{}", scopeName, streamName);
.entity(ModelHelper.encodeStreamResponse(scopeName, streamName, streamConfig)) .build()) .exceptionally(exception -> {
updateStreamRequest.setScalingPolicy(scalingConfig); StreamConfiguration streamConfig = getUpdateStreamConfig(updateStreamRequest); Assert.assertEquals(ScalingPolicy.ScaleType.FIXED_NUM_SEGMENTS, streamConfig.getScalingPolicy().getScaleType()); Assert.assertEquals(2, streamConfig.getScalingPolicy().getMinNumSegments()); updateStreamRequest.setRetentionPolicy(retentionConfig); streamConfig = getUpdateStreamConfig(updateStreamRequest); Assert.assertEquals(ScalingPolicy.ScaleType.BY_RATE_IN_EVENTS_PER_SEC, streamConfig.getScalingPolicy().getScaleType()); Assert.assertEquals(2, streamConfig.getScalingPolicy().getScaleFactor()); updateStreamRequest.setRetentionPolicy(retentionConfig); streamConfig = getUpdateStreamConfig(updateStreamRequest); Assert.assertEquals(ScalingPolicy.ScaleType.BY_RATE_IN_KBYTES_PER_SEC, streamConfig.getScalingPolicy().getScaleType()); Assert.assertEquals(23, streamConfig.getScalingPolicy().getScaleFactor());
createStreamRequest.setScalingPolicy(scalingConfig); StreamConfiguration streamConfig = getCreateStreamConfig(createStreamRequest); Assert.assertEquals(ScalingPolicy.ScaleType.FIXED_NUM_SEGMENTS, streamConfig.getScalingPolicy().getScaleType()); Assert.assertEquals(2, streamConfig.getScalingPolicy().getMinNumSegments()); createStreamRequest.setRetentionPolicy(retentionConfig); streamConfig = getCreateStreamConfig(createStreamRequest); Assert.assertEquals(ScalingPolicy.ScaleType.BY_RATE_IN_EVENTS_PER_SEC, streamConfig.getScalingPolicy().getScaleType()); Assert.assertEquals(2, streamConfig.getScalingPolicy().getScaleFactor()); createStreamRequest.setRetentionPolicy(retentionConfig); streamConfig = getCreateStreamConfig(createStreamRequest); Assert.assertEquals(ScalingPolicy.ScaleType.BY_RATE_IN_KBYTES_PER_SEC, streamConfig.getScalingPolicy().getScaleType()); Assert.assertEquals(23, streamConfig.getScalingPolicy().getScaleFactor());
streams.addStreamsItem(ModelHelper.encodeStreamResponse(scopeName, stream, config));
.scalingPolicy(ScalingPolicy.fixed(1)) .build(); StreamProperty streamProperty = encodeStreamResponse("scope", "stream", streamConfig); Assert.assertEquals("scope", streamProperty.getScopeName()); Assert.assertEquals("stream", streamProperty.getStreamName()); .retentionPolicy(RetentionPolicy.byTime(Duration.ofDays(100L))) .build(); streamProperty = encodeStreamResponse("scope", "stream", streamConfig); Assert.assertEquals(ScalingConfig.TypeEnum.BY_RATE_IN_KBYTES_PER_SEC, streamProperty.getScalingPolicy().getType()); .retentionPolicy(RetentionPolicy.bySizeBytes(1234L * 1024 * 1024)) .build(); streamProperty = encodeStreamResponse("scope", "stream", streamConfig); Assert.assertEquals(ScalingConfig.TypeEnum.BY_RATE_IN_EVENTS_PER_SEC, streamProperty.getScalingPolicy().getType());