Search in sources :

Example 1 with DeleteSegment

use of io.pravega.shared.protocol.netty.WireCommands.DeleteSegment in project pravega by pravega.

the class MockController method deleteSegment.

private boolean deleteSegment(String name, PravegaNodeUri uri) {
    CompletableFuture<Boolean> result = new CompletableFuture<>();
    FailingReplyProcessor replyProcessor = new FailingReplyProcessor() {

        @Override
        public void connectionDropped() {
            result.completeExceptionally(new ConnectionClosedException());
        }

        @Override
        public void wrongHost(WireCommands.WrongHost wrongHost) {
            result.completeExceptionally(new UnsupportedOperationException());
        }

        @Override
        public void segmentDeleted(WireCommands.SegmentDeleted segmentDeleted) {
            result.complete(true);
        }

        @Override
        public void noSuchSegment(WireCommands.NoSuchSegment noSuchSegment) {
            result.complete(false);
        }

        @Override
        public void processingFailure(Exception error) {
            result.completeExceptionally(error);
        }

        @Override
        public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
            result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
        }
    };
    DeleteSegment command = new WireCommands.DeleteSegment(idGenerator.get(), name, "");
    sendRequestOverNewConnection(command, replyProcessor, result);
    return getAndHandleExceptions(result, RuntimeException::new);
}
Also used : AuthenticationException(io.pravega.common.auth.AuthenticationException) FailingReplyProcessor(io.pravega.shared.protocol.netty.FailingReplyProcessor) DeleteSegment(io.pravega.shared.protocol.netty.WireCommands.DeleteSegment) ConnectionClosedException(io.pravega.client.stream.impl.ConnectionClosedException) WrongHost(io.pravega.shared.protocol.netty.WireCommands.WrongHost) AuthenticationException(io.pravega.common.auth.AuthenticationException) TxnFailedException(io.pravega.client.stream.TxnFailedException) ConnectionClosedException(io.pravega.client.stream.impl.ConnectionClosedException) CompletableFuture(java.util.concurrent.CompletableFuture)

Example 2 with DeleteSegment

use of io.pravega.shared.protocol.netty.WireCommands.DeleteSegment in project pravega by pravega.

the class MockController method deleteStream.

@Override
@Synchronized
public CompletableFuture<Boolean> deleteStream(String scope, String streamName) {
    Stream stream = new StreamImpl(scope, streamName);
    if (createdStreams.get(stream) == null) {
        return CompletableFuture.completedFuture(false);
    }
    for (Segment segment : getSegmentsForStream(stream)) {
        deleteSegment(segment.getScopedName(), new PravegaNodeUri(endpoint, port));
    }
    createdStreams.remove(stream);
    createdScopes.get(scope).remove(stream);
    return CompletableFuture.completedFuture(true);
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) StreamImpl(io.pravega.client.stream.impl.StreamImpl) Stream(io.pravega.client.stream.Stream) CreateSegment(io.pravega.shared.protocol.netty.WireCommands.CreateSegment) Segment(io.pravega.client.segment.impl.Segment) DeleteSegment(io.pravega.shared.protocol.netty.WireCommands.DeleteSegment) Synchronized(lombok.Synchronized)

Aggregations

DeleteSegment (io.pravega.shared.protocol.netty.WireCommands.DeleteSegment)2 Segment (io.pravega.client.segment.impl.Segment)1 Stream (io.pravega.client.stream.Stream)1 TxnFailedException (io.pravega.client.stream.TxnFailedException)1 ConnectionClosedException (io.pravega.client.stream.impl.ConnectionClosedException)1 StreamImpl (io.pravega.client.stream.impl.StreamImpl)1 AuthenticationException (io.pravega.common.auth.AuthenticationException)1 FailingReplyProcessor (io.pravega.shared.protocol.netty.FailingReplyProcessor)1 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)1 CreateSegment (io.pravega.shared.protocol.netty.WireCommands.CreateSegment)1 WrongHost (io.pravega.shared.protocol.netty.WireCommands.WrongHost)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Synchronized (lombok.Synchronized)1