use of io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus in project pravega by pravega.
the class ControllerServiceImplTest method updateStreamTests.
@Test
public void updateStreamTests() {
createScopeAndStream(SCOPE1, STREAM1, ScalingPolicy.fixed(2));
final StreamConfiguration configuration2 = StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(3)).build();
ResultObserver<UpdateStreamStatus> result2 = new ResultObserver<>();
this.controllerService.updateStream(ModelHelper.decode(SCOPE1, STREAM1, configuration2), result2);
UpdateStreamStatus updateStreamStatus = result2.get();
Assert.assertEquals(updateStreamStatus.getStatus(), UpdateStreamStatus.Status.SUCCESS);
// Update stream for non-existent stream.
ResultObserver<UpdateStreamStatus> result3 = new ResultObserver<>();
final StreamConfiguration configuration3 = StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build();
this.controllerService.updateStream(ModelHelper.decode(SCOPE1, "unknownstream", configuration3), result3);
updateStreamStatus = result3.get();
Assert.assertEquals(UpdateStreamStatus.Status.STREAM_NOT_FOUND, updateStreamStatus.getStatus());
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus in project pravega by pravega.
the class ControllerServiceImplTest method sealStreamTests.
@Test
public void sealStreamTests() {
CreateScopeStatus createScopeStatus;
CreateStreamStatus createStreamStatus;
UpdateStreamStatus updateStreamStatus;
final StreamConfiguration configuration1 = StreamConfiguration.builder().scope(SCOPE1).streamName(STREAM1).scalingPolicy(ScalingPolicy.fixed(4)).build();
// Create a test scope.
ResultObserver<CreateScopeStatus> result1 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE1), result1);
createScopeStatus = result1.get();
assertEquals("Create Scope", CreateScopeStatus.Status.SUCCESS, createScopeStatus.getStatus());
// Create a test stream.
ResultObserver<CreateStreamStatus> result2 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration1), result2);
createStreamStatus = result2.get();
assertEquals("Create stream", CreateStreamStatus.Status.SUCCESS, createStreamStatus.getStatus());
// Seal a test stream.
ResultObserver<UpdateStreamStatus> result3 = new ResultObserver<>();
this.controllerService.sealStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result3);
updateStreamStatus = result3.get();
assertEquals("Seal Stream", UpdateStreamStatus.Status.SUCCESS, updateStreamStatus.getStatus());
// Seal a non-existent stream.
ResultObserver<UpdateStreamStatus> result4 = new ResultObserver<>();
this.controllerService.sealStream(ModelHelper.createStreamInfo(SCOPE1, "dummyStream"), result4);
updateStreamStatus = result4.get();
assertEquals("Seal non-existent stream", UpdateStreamStatus.Status.STREAM_NOT_FOUND, updateStreamStatus.getStatus());
// Seal a non-existent stream.
ResultObserver<UpdateStreamStatus> result5 = new ResultObserver<>();
this.controllerService.sealStream(ModelHelper.createStreamInfo("dummyScope", STREAM1), result5);
updateStreamStatus = result5.get();
assertEquals("Seal non-existent stream", UpdateStreamStatus.Status.STREAM_NOT_FOUND, updateStreamStatus.getStatus());
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus in project pravega by pravega.
the class ControllerServiceImplTest method deleteStreamTests.
@Test
public void deleteStreamTests() {
CreateScopeStatus createScopeStatus;
CreateStreamStatus createStreamStatus;
DeleteStreamStatus deleteStreamStatus;
final StreamConfiguration configuration1 = StreamConfiguration.builder().scope(SCOPE1).streamName(STREAM1).scalingPolicy(ScalingPolicy.fixed(4)).build();
// Create a test scope.
ResultObserver<CreateScopeStatus> result1 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE1), result1);
createScopeStatus = result1.get();
assertEquals("Create Scope", CreateScopeStatus.Status.SUCCESS, createScopeStatus.getStatus());
// Try deleting a non-existent stream.
ResultObserver<DeleteStreamStatus> result2 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo(SCOPE3, "dummyStream"), result2);
deleteStreamStatus = result2.get();
assertEquals("Delete Non-existent stream", DeleteStreamStatus.Status.STREAM_NOT_FOUND, deleteStreamStatus.getStatus());
// Try deleting a non-existent stream.
ResultObserver<DeleteStreamStatus> result3 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo("dummyScope", "dummyStream"), result3);
deleteStreamStatus = result3.get();
assertEquals("Delete Non-existent stream", DeleteStreamStatus.Status.STREAM_NOT_FOUND, deleteStreamStatus.getStatus());
// Create a test stream.
ResultObserver<CreateStreamStatus> result4 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration1), result4);
createStreamStatus = result4.get();
Assert.assertEquals("Create stream", CreateStreamStatus.Status.SUCCESS, createStreamStatus.getStatus());
// Try deleting the test stream without sealing it first.
ResultObserver<DeleteStreamStatus> result5 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result5);
deleteStreamStatus = result5.get();
assertEquals("Delete non-sealed stream", DeleteStreamStatus.Status.STREAM_NOT_SEALED, deleteStreamStatus.getStatus());
// Seal the test stream.
ResultObserver<UpdateStreamStatus> result6 = new ResultObserver<>();
this.controllerService.sealStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result6);
UpdateStreamStatus updateStreamStatus = result6.get();
assertEquals("Seal stream", UpdateStreamStatus.Status.SUCCESS, updateStreamStatus.getStatus());
// Delete the sealed stream.
ResultObserver<DeleteStreamStatus> result7 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result7);
deleteStreamStatus = result7.get();
assertEquals("Delete sealed stream", DeleteStreamStatus.Status.SUCCESS, deleteStreamStatus.getStatus());
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus in project pravega by pravega.
the class ControllerImpl method sealStream.
@Override
public CompletableFuture<Boolean> sealStream(final String scope, final String streamName) {
Exceptions.checkNotClosed(closed.get(), this);
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(streamName, "streamName");
long traceId = LoggerHelpers.traceEnter(log, "sealStream", scope, streamName);
final CompletableFuture<UpdateStreamStatus> result = this.retryConfig.runAsync(() -> {
RPCAsyncCallback<UpdateStreamStatus> callback = new RPCAsyncCallback<>();
client.sealStream(ModelHelper.createStreamInfo(scope, streamName), callback);
return callback.getFuture();
}, this.executor);
return result.thenApply(x -> {
switch(x.getStatus()) {
case FAILURE:
log.warn("Failed to seal stream: {}", streamName);
throw new ControllerFailureException("Failed to seal stream: " + streamName);
case SCOPE_NOT_FOUND:
log.warn("Scope not found: {}", scope);
throw new InvalidStreamException("Scope does not exist: " + scope);
case STREAM_NOT_FOUND:
log.warn("Stream does not exist: {}", streamName);
throw new InvalidStreamException("Stream does not exist: " + streamName);
case SUCCESS:
log.info("Successfully sealed stream: {}", streamName);
return true;
case UNRECOGNIZED:
default:
throw new ControllerFailureException("Unknown return status scealing stream " + streamName + " " + x.getStatus());
}
}).whenComplete((x, e) -> {
if (e != null) {
log.warn("sealStream failed: ", e);
}
LoggerHelpers.traceLeave(log, "sealStream", traceId);
});
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus in project pravega by pravega.
the class ControllerServiceImplTest method truncateSealedStreamTest.
@Test
public void truncateSealedStreamTest() {
CreateScopeStatus createScopeStatus;
CreateStreamStatus createStreamStatus;
UpdateStreamStatus truncateStreamStatus;
final StreamConfiguration configuration1 = StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(4)).build();
// Create a test scope.
ResultObserver<CreateScopeStatus> result1 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE1), result1);
createScopeStatus = result1.get();
assertEquals("Create Scope", CreateScopeStatus.Status.SUCCESS, createScopeStatus.getStatus());
// Create a test stream.
ResultObserver<CreateStreamStatus> result2 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(SCOPE1, STREAM1, configuration1), result2);
createStreamStatus = result2.get();
Assert.assertEquals("Create stream", CreateStreamStatus.Status.SUCCESS, createStreamStatus.getStatus());
// Seal the test stream.
ResultObserver<UpdateStreamStatus> result3 = new ResultObserver<>();
this.controllerService.sealStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result3);
UpdateStreamStatus updateStreamStatus = result3.get();
assertEquals("Seal stream", UpdateStreamStatus.Status.SUCCESS, updateStreamStatus.getStatus());
// Truncate the sealed test stream
ResultObserver<UpdateStreamStatus> result4 = new ResultObserver<>();
this.controllerService.truncateStream(Controller.StreamCut.newBuilder().setStreamInfo(StreamInfo.newBuilder().setScope(SCOPE1).setStream(STREAM1).build()).putCut(0, 0).putCut(1, 0).putCut(2, 0).putCut(3, 0).build(), result4);
truncateStreamStatus = result4.get();
assertEquals("Truncate sealed stream", UpdateStreamStatus.Status.STREAM_SEALED, truncateStreamStatus.getStatus());
}
Aggregations