Search in sources :

Example 11 with SegmentWithRange

use of io.pravega.client.stream.impl.SegmentWithRange in project pravega by pravega.

the class ControllerImpl method getSuccessors.

@Override
public CompletableFuture<StreamSegmentsWithPredecessors> getSuccessors(Segment segment) {
    Exceptions.checkNotClosed(closed.get(), this);
    final long requestId = requestIdGenerator.get();
    long traceId = LoggerHelpers.traceEnter(log, "getSuccessors", segment, requestId);
    final CompletableFuture<SuccessorResponse> resultFuture = this.retryConfig.runAsync(() -> {
        RPCAsyncCallback<SuccessorResponse> callback = new RPCAsyncCallback<>(requestId, "getSuccessors", segment);
        new ControllerClientTagger(client, timeoutMillis).withTag(requestId, GET_SEGMENTS_IMMEDIATELY_FOLLOWING, segment.getScopedName()).getSegmentsImmediatelyFollowing(ModelHelper.decode(segment), callback);
        return callback.getFuture();
    }, this.executor);
    return resultFuture.thenApplyAsync(successors -> {
        log.debug(requestId, "Received the following data from the controller {}", successors.getSegmentsList());
        Map<SegmentWithRange, List<Long>> result = new HashMap<>();
        for (SuccessorResponse.SegmentEntry entry : successors.getSegmentsList()) {
            result.put(encode(entry.getSegment()), entry.getValueList());
        }
        return new StreamSegmentsWithPredecessors(result, successors.getDelegationToken());
    }, this.executor).whenComplete((x, e) -> {
        if (e != null) {
            log.warn(requestId, "getSuccessors of segment {} failed: ", segment.getSegmentId(), e);
        }
        LoggerHelpers.traceLeave(log, "getSuccessors", traceId, requestId);
    });
}
Also used : StreamCut(io.pravega.client.stream.StreamCut) StreamConfig(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig) NegotiationType(io.grpc.netty.shaded.io.grpc.netty.NegotiationType) MoreCallCredentials(io.grpc.auth.MoreCallCredentials) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) PingTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest) DELETE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_STREAM) SegmentRanges(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges) StreamSegments(io.pravega.client.stream.impl.StreamSegments) NoSuchScopeException(io.pravega.client.stream.NoSuchScopeException) TRUNCATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.TRUNCATE_STREAM) AccessOperation(io.pravega.shared.security.auth.AccessOperation) Map(java.util.Map) SubscriberStreamCut(io.pravega.controller.stream.api.grpc.v1.Controller.SubscriberStreamCut) LIST_SCOPES(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SCOPES) UPDATE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_READER_GROUP) UPDATE_TRUNCATION_STREAM_CUT(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_TRUNCATION_STREAM_CUT) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) GET_SEGMENTS_IMMEDIATELY_FOLLOWING(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_IMMEDIATELY_FOLLOWING) ReaderGroupInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupInfo) REMOVE_WRITER(io.pravega.shared.controller.tracing.RPCTracingTags.REMOVE_WRITER) GET_SEGMENTS_BETWEEN_STREAM_CUTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_BETWEEN_STREAM_CUTS) LIST_STREAMS_IN_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_STREAMS_IN_SCOPE) SslContextBuilder(io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder) RequestTracker(io.pravega.common.tracing.RequestTracker) ScopesResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScopesResponse) SSLException(javax.net.ssl.SSLException) KVTablesInScopeRequest(io.pravega.controller.stream.api.grpc.v1.Controller.KVTablesInScopeRequest) GET_STREAM_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_STREAM_CONFIGURATION) Futures(io.pravega.common.concurrent.Futures) KeyValueTableSegments(io.pravega.client.tables.impl.KeyValueTableSegments) SegmentId(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId) StreamCutRangeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse) CreateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateReaderGroupResponse) LIST_KEY_VALUE_TABLES(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_KEY_VALUE_TABLES) KeyValueTableConfig(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig) GrpcSslContexts(io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts) Exceptions(io.pravega.common.Exceptions) ScopeInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo) StreamsInScopeWithTagRequest(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeWithTagRequest) ModelHelper.encode(io.pravega.client.control.impl.ModelHelper.encode) GET_KEY_VALUE_TABLE_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_KEY_VALUE_TABLE_CONFIGURATION) Supplier(java.util.function.Supplier) UpdateSubscriberStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateSubscriberStatus) PingFailedException(io.pravega.client.stream.PingFailedException) Strings(com.google.common.base.Strings) Code(io.grpc.Status.Code) NodeUri(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri) ReaderGroupConfiguration(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) GET_SUCCESSORS_FROM_CUT(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SUCCESSORS_FROM_CUT) ControllerServiceGrpc(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc) START_SCALE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.START_SCALE_STREAM) StreamSegmentsWithPredecessors(io.pravega.client.stream.impl.StreamSegmentsWithPredecessors) ExistsResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ExistsResponse) RemoveWriterResponse(io.pravega.controller.stream.api.grpc.v1.Controller.RemoveWriterResponse) Callbacks(io.pravega.common.function.Callbacks) AsyncIterator(io.pravega.common.util.AsyncIterator) SegmentRange(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange) WriterPosition(io.pravega.client.stream.impl.WriterPosition) File(java.io.File) StatusRuntimeException(io.grpc.StatusRuntimeException) CREATE_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_TRANSACTION) RPCTracingHelpers(io.pravega.shared.controller.tracing.RPCTracingHelpers) LIST_STREAMS_IN_SCOPE_FOR_TAG(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_STREAMS_IN_SCOPE_FOR_TAG) TreeMap(java.util.TreeMap) TxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus) Preconditions(com.google.common.base.Preconditions) DeleteReaderGroupStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteReaderGroupStatus) SegmentsAtTime(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentsAtTime) TxnFailedException(io.pravega.client.stream.TxnFailedException) CreateKeyValueTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateKeyValueTableStatus) GET_CURRENT_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_CURRENT_SEGMENTS) CHECK_TRANSACTION_STATE(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_TRANSACTION_STATE) CREATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_STREAM) ManagedChannel(io.grpc.ManagedChannel) Retry(io.pravega.common.util.Retry) LoggerFactory(org.slf4j.LoggerFactory) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) ReaderGroupNotFoundException(io.pravega.client.stream.ReaderGroupNotFoundException) StreamsInScopeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeResponse) ContinuationToken(io.pravega.controller.stream.api.grpc.v1.Controller.ContinuationToken) GetSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest) StreamObserver(io.grpc.stub.StreamObserver) TagLogger(io.pravega.common.tracing.TagLogger) ControllerServiceStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub) CREATE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_KEY_VALUE_TABLE) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo) Stream(io.pravega.client.stream.Stream) KVTablesInScopeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KVTablesInScopeResponse) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) SubscribersResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SubscribersResponse) Transaction(io.pravega.client.stream.Transaction) DELETE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_KEY_VALUE_TABLE) TxnSegments(io.pravega.client.stream.impl.TxnSegments) RetryAndThrowConditionally(io.pravega.common.util.Retry.RetryAndThrowConditionally) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) CHECK_SCOPE_EXISTS(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_SCOPE_EXISTS) LIST_SUBSCRIBERS(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SUBSCRIBERS) CHECK_STREAM_EXISTS(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_STREAM_EXISTS) CREATE_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_SCOPE) Collection(java.util.Collection) DelegationToken(io.pravega.controller.stream.api.grpc.v1.Controller.DelegationToken) CompletionException(java.util.concurrent.CompletionException) UUID(java.util.UUID) COMMIT_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.COMMIT_TRANSACTION) NavigableMap(java.util.NavigableMap) Collectors(java.util.stream.Collectors) GET_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS) GET_EPOCH_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_EPOCH_SEGMENTS) SEAL_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.SEAL_STREAM) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) List(java.util.List) ABORT_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.ABORT_TRANSACTION) CreateTxnResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse) GET_URI(io.pravega.shared.controller.tracing.RPCTracingTags.GET_URI) GetEpochSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetEpochSegmentsRequest) DELETE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_READER_GROUP) TimestampFromWriter(io.pravega.controller.stream.api.grpc.v1.Controller.TimestampFromWriter) DELETE_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_SCOPE) PING_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.PING_TRANSACTION) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) DELETE_SCOPE_RECURSIVE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_SCOPE_RECURSIVE) Segment(io.pravega.client.segment.impl.Segment) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) StreamImpl(io.pravega.client.stream.impl.StreamImpl) ScaleStatusRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest) KeyValueTableConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfigResponse) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IS_SEGMENT_OPEN(io.pravega.shared.controller.tracing.RPCTracingTags.IS_SEGMENT_OPEN) ScaleStatusResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) SuccessorResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse) GET_OR_REFRESH_DELEGATION_TOKEN_FOR(io.pravega.shared.controller.tracing.RPCTracingTags.GET_OR_REFRESH_DELEGATION_TOKEN_FOR) ScaleRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleRequest) DeleteKVTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteKVTableStatus) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE) ScopesRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScopesRequest) DeleteStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus) NOTE_TIMESTAMP_FROM_WRITER(io.pravega.shared.controller.tracing.RPCTracingTags.NOTE_TIMESTAMP_FROM_WRITER) CHECK_SCALE(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_SCALE) NettyChannelBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder) UPDATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_STREAM) CREATE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_READER_GROUP) ScaleResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse) SCALE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.SCALE_STREAM) LoggerHelpers(io.pravega.common.LoggerHelpers) UpdateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateReaderGroupResponse) NameUtils(io.pravega.shared.NameUtils) TimestampResponse(io.pravega.controller.stream.api.grpc.v1.Controller.TimestampResponse) StreamsInScopeRequest(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeRequest) RemoveWriterRequest(io.pravega.controller.stream.api.grpc.v1.Controller.RemoveWriterRequest) GET_READER_GROUP_CONFIG(io.pravega.shared.controller.tracing.RPCTracingTags.GET_READER_GROUP_CONFIG) StreamSegmentSuccessors(io.pravega.client.stream.impl.StreamSegmentSuccessors) TimeUnit(java.util.concurrent.TimeUnit) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) AbstractMap(java.util.AbstractMap) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) ContinuationTokenAsyncIterator(io.pravega.common.util.ContinuationTokenAsyncIterator) InvalidStreamException(io.pravega.client.stream.InvalidStreamException) Credentials(io.pravega.shared.security.auth.Credentials) VisibleForTesting(com.google.common.annotations.VisibleForTesting) RandomFactory(io.pravega.common.hash.RandomFactory) TxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest) ReaderGroupConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfigResponse) SegmentValidityResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentValidityResponse) Collections(java.util.Collections) StreamSegmentsWithPredecessors(io.pravega.client.stream.impl.StreamSegmentsWithPredecessors) SuccessorResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse) Map(java.util.Map) TreeMap(java.util.TreeMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap)

Example 12 with SegmentWithRange

use of io.pravega.client.stream.impl.SegmentWithRange in project pravega by pravega.

the class ControllerImpl method getCurrentSegmentsForKeyValueTable.

@Override
public CompletableFuture<KeyValueTableSegments> getCurrentSegmentsForKeyValueTable(String scope, String kvtName) {
    Exceptions.checkNotClosed(closed.get(), this);
    Exceptions.checkNotNullOrEmpty(scope, "scope");
    Exceptions.checkNotNullOrEmpty(kvtName, "stream");
    long traceId = LoggerHelpers.traceEnter(log, "getCurrentSegmentsForKeyValueTable", scope, kvtName);
    final long requestId = requestIdGenerator.get();
    final CompletableFuture<SegmentRanges> result = this.retryConfig.runAsync(() -> {
        RPCAsyncCallback<SegmentRanges> callback = new RPCAsyncCallback<>(traceId, "getCurrentSegmentsKeyValueTable", scope, kvtName);
        new ControllerClientTagger(client, timeoutMillis).withTag(requestId, GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE, scope, kvtName).getCurrentSegmentsKeyValueTable(ModelHelper.createKeyValueTableInfo(scope, kvtName), callback);
        return callback.getFuture();
    }, this.executor);
    return result.thenApplyAsync(ranges -> {
        log.debug(requestId, "Received the following data from the controller {}", ranges.getSegmentRangesList());
        NavigableMap<Double, SegmentWithRange> rangeMap = new TreeMap<>();
        for (SegmentRange r : ranges.getSegmentRangesList()) {
            Preconditions.checkState(r.getMinKey() <= r.getMaxKey(), "Min keyrange %s was not less than maximum keyRange %s for segment %s", r.getMinKey(), r.getMaxKey(), r.getSegmentId());
            rangeMap.put(r.getMaxKey(), new SegmentWithRange(encode(r.getSegmentId()), r.getMinKey(), r.getMaxKey()));
        }
        return new KeyValueTableSegments(rangeMap);
    }, this.executor).whenComplete((x, e) -> {
        if (e != null) {
            log.warn(requestId, "getCurrentSegmentsForKeyValueTable for {}/{} failed: ", scope, kvtName, e);
        }
        LoggerHelpers.traceLeave(log, "getCurrentSegmentsForKeyValueTable", traceId);
    });
}
Also used : StreamCut(io.pravega.client.stream.StreamCut) StreamConfig(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig) NegotiationType(io.grpc.netty.shaded.io.grpc.netty.NegotiationType) MoreCallCredentials(io.grpc.auth.MoreCallCredentials) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) PingTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest) DELETE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_STREAM) SegmentRanges(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges) StreamSegments(io.pravega.client.stream.impl.StreamSegments) NoSuchScopeException(io.pravega.client.stream.NoSuchScopeException) TRUNCATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.TRUNCATE_STREAM) AccessOperation(io.pravega.shared.security.auth.AccessOperation) Map(java.util.Map) SubscriberStreamCut(io.pravega.controller.stream.api.grpc.v1.Controller.SubscriberStreamCut) LIST_SCOPES(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SCOPES) UPDATE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_READER_GROUP) UPDATE_TRUNCATION_STREAM_CUT(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_TRUNCATION_STREAM_CUT) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) GET_SEGMENTS_IMMEDIATELY_FOLLOWING(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_IMMEDIATELY_FOLLOWING) ReaderGroupInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupInfo) REMOVE_WRITER(io.pravega.shared.controller.tracing.RPCTracingTags.REMOVE_WRITER) GET_SEGMENTS_BETWEEN_STREAM_CUTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_BETWEEN_STREAM_CUTS) LIST_STREAMS_IN_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_STREAMS_IN_SCOPE) SslContextBuilder(io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder) RequestTracker(io.pravega.common.tracing.RequestTracker) ScopesResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScopesResponse) SSLException(javax.net.ssl.SSLException) KVTablesInScopeRequest(io.pravega.controller.stream.api.grpc.v1.Controller.KVTablesInScopeRequest) GET_STREAM_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_STREAM_CONFIGURATION) Futures(io.pravega.common.concurrent.Futures) KeyValueTableSegments(io.pravega.client.tables.impl.KeyValueTableSegments) SegmentId(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId) StreamCutRangeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse) CreateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateReaderGroupResponse) LIST_KEY_VALUE_TABLES(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_KEY_VALUE_TABLES) KeyValueTableConfig(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig) GrpcSslContexts(io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts) Exceptions(io.pravega.common.Exceptions) ScopeInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo) StreamsInScopeWithTagRequest(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeWithTagRequest) ModelHelper.encode(io.pravega.client.control.impl.ModelHelper.encode) GET_KEY_VALUE_TABLE_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_KEY_VALUE_TABLE_CONFIGURATION) Supplier(java.util.function.Supplier) UpdateSubscriberStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateSubscriberStatus) PingFailedException(io.pravega.client.stream.PingFailedException) Strings(com.google.common.base.Strings) Code(io.grpc.Status.Code) NodeUri(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri) ReaderGroupConfiguration(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) GET_SUCCESSORS_FROM_CUT(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SUCCESSORS_FROM_CUT) ControllerServiceGrpc(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc) START_SCALE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.START_SCALE_STREAM) StreamSegmentsWithPredecessors(io.pravega.client.stream.impl.StreamSegmentsWithPredecessors) ExistsResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ExistsResponse) RemoveWriterResponse(io.pravega.controller.stream.api.grpc.v1.Controller.RemoveWriterResponse) Callbacks(io.pravega.common.function.Callbacks) AsyncIterator(io.pravega.common.util.AsyncIterator) SegmentRange(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange) WriterPosition(io.pravega.client.stream.impl.WriterPosition) File(java.io.File) StatusRuntimeException(io.grpc.StatusRuntimeException) CREATE_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_TRANSACTION) RPCTracingHelpers(io.pravega.shared.controller.tracing.RPCTracingHelpers) LIST_STREAMS_IN_SCOPE_FOR_TAG(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_STREAMS_IN_SCOPE_FOR_TAG) TreeMap(java.util.TreeMap) TxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus) Preconditions(com.google.common.base.Preconditions) DeleteReaderGroupStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteReaderGroupStatus) SegmentsAtTime(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentsAtTime) TxnFailedException(io.pravega.client.stream.TxnFailedException) CreateKeyValueTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateKeyValueTableStatus) GET_CURRENT_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_CURRENT_SEGMENTS) CHECK_TRANSACTION_STATE(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_TRANSACTION_STATE) CREATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_STREAM) ManagedChannel(io.grpc.ManagedChannel) Retry(io.pravega.common.util.Retry) LoggerFactory(org.slf4j.LoggerFactory) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) ReaderGroupNotFoundException(io.pravega.client.stream.ReaderGroupNotFoundException) StreamsInScopeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeResponse) ContinuationToken(io.pravega.controller.stream.api.grpc.v1.Controller.ContinuationToken) GetSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest) StreamObserver(io.grpc.stub.StreamObserver) TagLogger(io.pravega.common.tracing.TagLogger) ControllerServiceStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub) CREATE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_KEY_VALUE_TABLE) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo) Stream(io.pravega.client.stream.Stream) KVTablesInScopeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KVTablesInScopeResponse) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) SubscribersResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SubscribersResponse) Transaction(io.pravega.client.stream.Transaction) DELETE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_KEY_VALUE_TABLE) TxnSegments(io.pravega.client.stream.impl.TxnSegments) RetryAndThrowConditionally(io.pravega.common.util.Retry.RetryAndThrowConditionally) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) CHECK_SCOPE_EXISTS(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_SCOPE_EXISTS) LIST_SUBSCRIBERS(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SUBSCRIBERS) CHECK_STREAM_EXISTS(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_STREAM_EXISTS) CREATE_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_SCOPE) Collection(java.util.Collection) DelegationToken(io.pravega.controller.stream.api.grpc.v1.Controller.DelegationToken) CompletionException(java.util.concurrent.CompletionException) UUID(java.util.UUID) COMMIT_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.COMMIT_TRANSACTION) NavigableMap(java.util.NavigableMap) Collectors(java.util.stream.Collectors) GET_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS) GET_EPOCH_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_EPOCH_SEGMENTS) SEAL_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.SEAL_STREAM) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) List(java.util.List) ABORT_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.ABORT_TRANSACTION) CreateTxnResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse) GET_URI(io.pravega.shared.controller.tracing.RPCTracingTags.GET_URI) GetEpochSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetEpochSegmentsRequest) DELETE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_READER_GROUP) TimestampFromWriter(io.pravega.controller.stream.api.grpc.v1.Controller.TimestampFromWriter) DELETE_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_SCOPE) PING_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.PING_TRANSACTION) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) DELETE_SCOPE_RECURSIVE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_SCOPE_RECURSIVE) Segment(io.pravega.client.segment.impl.Segment) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) StreamImpl(io.pravega.client.stream.impl.StreamImpl) ScaleStatusRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest) KeyValueTableConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfigResponse) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IS_SEGMENT_OPEN(io.pravega.shared.controller.tracing.RPCTracingTags.IS_SEGMENT_OPEN) ScaleStatusResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) SuccessorResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse) GET_OR_REFRESH_DELEGATION_TOKEN_FOR(io.pravega.shared.controller.tracing.RPCTracingTags.GET_OR_REFRESH_DELEGATION_TOKEN_FOR) ScaleRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleRequest) DeleteKVTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteKVTableStatus) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE) ScopesRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScopesRequest) DeleteStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus) NOTE_TIMESTAMP_FROM_WRITER(io.pravega.shared.controller.tracing.RPCTracingTags.NOTE_TIMESTAMP_FROM_WRITER) CHECK_SCALE(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_SCALE) NettyChannelBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder) UPDATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_STREAM) CREATE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_READER_GROUP) ScaleResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse) SCALE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.SCALE_STREAM) LoggerHelpers(io.pravega.common.LoggerHelpers) UpdateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateReaderGroupResponse) NameUtils(io.pravega.shared.NameUtils) TimestampResponse(io.pravega.controller.stream.api.grpc.v1.Controller.TimestampResponse) StreamsInScopeRequest(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeRequest) RemoveWriterRequest(io.pravega.controller.stream.api.grpc.v1.Controller.RemoveWriterRequest) GET_READER_GROUP_CONFIG(io.pravega.shared.controller.tracing.RPCTracingTags.GET_READER_GROUP_CONFIG) StreamSegmentSuccessors(io.pravega.client.stream.impl.StreamSegmentSuccessors) TimeUnit(java.util.concurrent.TimeUnit) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) AbstractMap(java.util.AbstractMap) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) ContinuationTokenAsyncIterator(io.pravega.common.util.ContinuationTokenAsyncIterator) InvalidStreamException(io.pravega.client.stream.InvalidStreamException) Credentials(io.pravega.shared.security.auth.Credentials) VisibleForTesting(com.google.common.annotations.VisibleForTesting) RandomFactory(io.pravega.common.hash.RandomFactory) TxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest) ReaderGroupConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfigResponse) SegmentValidityResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentValidityResponse) Collections(java.util.Collections) SegmentRange(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange) NavigableMap(java.util.NavigableMap) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) KeyValueTableSegments(io.pravega.client.tables.impl.KeyValueTableSegments) SegmentRanges(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges)

Example 13 with SegmentWithRange

use of io.pravega.client.stream.impl.SegmentWithRange in project pravega by pravega.

the class ControllerImpl method convert.

private TxnSegments convert(CreateTxnResponse response) {
    NavigableMap<Double, SegmentWithRange> rangeMap = new TreeMap<>();
    for (SegmentRange r : response.getActiveSegmentsList()) {
        Preconditions.checkState(r.getMinKey() <= r.getMaxKey());
        rangeMap.put(r.getMaxKey(), new SegmentWithRange(encode(r.getSegmentId()), r.getMinKey(), r.getMaxKey()));
    }
    StreamSegments segments = new StreamSegments(rangeMap);
    return new TxnSegments(segments, encode(response.getTxnId()));
}
Also used : SegmentRange(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange) TxnSegments(io.pravega.client.stream.impl.TxnSegments) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) TreeMap(java.util.TreeMap) StreamSegments(io.pravega.client.stream.impl.StreamSegments)

Example 14 with SegmentWithRange

use of io.pravega.client.stream.impl.SegmentWithRange in project pravega by pravega.

the class ControllerImpl method getStreamSegments.

private StreamSegments getStreamSegments(final SegmentRanges ranges, long requestId) {
    log.debug(requestId, "Received the following data from the controller {}", ranges.getSegmentRangesList());
    NavigableMap<Double, SegmentWithRange> rangeMap = new TreeMap<>();
    for (SegmentRange r : ranges.getSegmentRangesList()) {
        Preconditions.checkState(r.getMinKey() <= r.getMaxKey(), "Min keyrange %s was not less than maximum keyRange %s for segment %s", r.getMinKey(), r.getMaxKey(), r.getSegmentId());
        rangeMap.put(r.getMaxKey(), new SegmentWithRange(encode(r.getSegmentId()), r.getMinKey(), r.getMaxKey()));
    }
    return new StreamSegments(rangeMap);
}
Also used : SegmentRange(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) TreeMap(java.util.TreeMap) StreamSegments(io.pravega.client.stream.impl.StreamSegments)

Example 15 with SegmentWithRange

use of io.pravega.client.stream.impl.SegmentWithRange in project pravega by pravega.

the class MockStreamManager method createReaderGroup.

@Override
public boolean createReaderGroup(String groupName, ReaderGroupConfig config) {
    NameUtils.validateReaderGroupName(groupName);
    createStreamHelper(NameUtils.getStreamForReaderGroup(groupName), StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
    if (ReaderGroupConfig.DEFAULT_UUID.equals(config.getReaderGroupId())) {
        config = ReaderGroupConfig.cloneConfig(config, UUID.randomUUID(), 0L);
    }
    @Cleanup StateSynchronizer<ReaderGroupState> synchronizer = clientFactory.createStateSynchronizer(NameUtils.getStreamForReaderGroup(groupName), new ReaderGroupStateUpdatesSerializer(), new ReaderGroupStateInitSerializer(), SynchronizerConfig.builder().build());
    Futures.getThrowingException(controller.createReaderGroup(scope, groupName, config));
    Map<SegmentWithRange, Long> segments = ReaderGroupImpl.getSegmentsForStreams(controller, config);
    synchronizer.initialize(new ReaderGroupState.ReaderGroupStateInit(config, segments, getEndSegmentsForStreams(config), false));
    return true;
}
Also used : ReaderGroupStateUpdatesSerializer(io.pravega.client.admin.impl.ReaderGroupManagerImpl.ReaderGroupStateUpdatesSerializer) ReaderGroupStateInitSerializer(io.pravega.client.admin.impl.ReaderGroupManagerImpl.ReaderGroupStateInitSerializer) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) ReaderGroupState(io.pravega.client.stream.impl.ReaderGroupState) Cleanup(lombok.Cleanup)

Aggregations

SegmentWithRange (io.pravega.client.stream.impl.SegmentWithRange)15 Segment (io.pravega.client.segment.impl.Segment)8 TreeMap (java.util.TreeMap)7 StreamSegments (io.pravega.client.stream.impl.StreamSegments)5 SegmentRange (io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ReaderGroupConfig (io.pravega.client.stream.ReaderGroupConfig)3 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)3 TxnSegments (io.pravega.client.stream.impl.TxnSegments)3 KeyValueTableSegments (io.pravega.client.tables.impl.KeyValueTableSegments)3 Map (java.util.Map)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Preconditions (com.google.common.base.Preconditions)2 Strings (com.google.common.base.Strings)2 ManagedChannel (io.grpc.ManagedChannel)2 ManagedChannelBuilder (io.grpc.ManagedChannelBuilder)2 Code (io.grpc.Status.Code)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 MoreCallCredentials (io.grpc.auth.MoreCallCredentials)2