Search in sources :

Example 6 with CreateSegment

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

the class MockController method createStream.

@Override
@Synchronized
public CompletableFuture<Boolean> createStream(StreamConfiguration streamConfig) {
    Stream stream = new StreamImpl(streamConfig.getScope(), streamConfig.getStreamName());
    if (createdStreams.get(stream) != null) {
        return CompletableFuture.completedFuture(false);
    }
    if (createdScopes.get(streamConfig.getScope()) == null) {
        return Futures.failedFuture(new IllegalArgumentException("Scope does not exit."));
    }
    createdStreams.put(stream, streamConfig);
    createdScopes.get(streamConfig.getScope()).add(stream);
    for (Segment segment : getSegmentsForStream(stream)) {
        createSegment(segment.getScopedName(), new PravegaNodeUri(endpoint, port));
    }
    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

CreateSegment (io.pravega.shared.protocol.netty.WireCommands.CreateSegment)6 SegmentCreated (io.pravega.shared.protocol.netty.WireCommands.SegmentCreated)4 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)3 UUID (java.util.UUID)3 ByteBuf (io.netty.buffer.ByteBuf)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)2 Stream (io.pravega.client.stream.Stream)2 StreamImpl (io.pravega.client.stream.impl.StreamImpl)2 AuthenticationException (io.pravega.common.auth.AuthenticationException)2 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)2 WrongHost (io.pravega.shared.protocol.netty.WireCommands.WrongHost)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 AuthHandler (io.pravega.auth.AuthHandler)1 READ (io.pravega.auth.AuthHandler.Permissions.READ)1 READ_UPDATE (io.pravega.auth.AuthHandler.Permissions.READ_UPDATE)1 SegmentRange (io.pravega.client.batch.SegmentRange)1 ClientConnection (io.pravega.client.netty.impl.ClientConnection)1