public CompletableFuture < DeleteStreamStatus . Status > deleteStream ( final String scope , final String stream , final OperationContext contextOpt ) { final OperationContext context = contextOpt == null ? streamMetadataStore . createContext ( scope , stream ) : contextOpt ; final long requestId = requestTracker . getRequestIdFor ( "deleteStream" , scope , stream ) ; return streamMetadataStore . getState ( scope , stream , false , context , executor ) . thenCompose ( state -> { if ( ! state . equals ( State . SEALED ) ) { return CompletableFuture . completedFuture ( false ) ; } else { return streamMetadataStore . getCreationTime ( scope , stream , context , executor ) . thenApply ( time -> new DeleteStreamEvent ( scope , stream , requestId , time ) ) . thenCompose ( event -> writeEvent ( event ) ) . thenApply ( x -> true ) ; } } ) . thenCompose ( result -> { if ( result ) { return checkDone ( ( ) -> isDeleted ( scope , stream ) ) . thenApply ( x -> DeleteStreamStatus . Status . SUCCESS ) ; } else { return CompletableFuture . completedFuture ( DeleteStreamStatus . Status . STREAM_NOT_SEALED ) ; } } ) . exceptionally ( ex -> { log . warn ( requestId , "Exception thrown while deleting stream {}" , ex . getMessage ( ) ) ; return handleDeleteStreamError ( ex , requestId ) ; } ) ; }
Delete a stream . Precondition for deleting a stream is that the stream sholud be sealed .