Search in sources :

Example 56 with OperationContext

use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.

the class ControllerService method listKeyValueTables.

/**
 * List existing KeyValueTables in specified scope.
 *
 * @param scope Name of the scope.
 * @param token continuation token
 * @param limit limit for number of KeyValueTables to return.
 * @param requestId  request id
 * @return List of KeyValueTables in scope.
 */
public CompletableFuture<Pair<List<String>, String>> listKeyValueTables(final String scope, final String token, final int limit, final long requestId) {
    Exceptions.checkNotNullOrEmpty(scope, "scope");
    OperationContext context = streamStore.createScopeContext(scope, requestId);
    return kvtMetadataStore.listKeyValueTables(scope, token, limit, context, executor);
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext)

Example 57 with OperationContext

use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.

the class ControllerService method deleteScope.

/**
 * Controller Service API to delete scope.
 *
 * @param scope Name of scope to be deleted.
 * @param requestId request id
 * @return Status of delete scope.
 */
public CompletableFuture<DeleteScopeStatus> deleteScope(final String scope, final long requestId) {
    Exceptions.checkNotNullOrEmpty(scope, "scope");
    Timer timer = new Timer();
    OperationContext context = streamStore.createScopeContext(scope, requestId);
    return streamStore.deleteScope(scope, context, executor).thenApply(r -> reportDeleteScopeMetrics(scope, r, timer.getElapsed()));
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) Timer(io.pravega.common.Timer)

Example 58 with OperationContext

use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.

the class ControllerService method listStreamsInScope.

/**
 * List existing streams in scopes.
 *
 * @param scope Name of the scope.
 * @param requestId request id
 * @return List of streams in scope.
 */
public CompletableFuture<Map<String, StreamConfiguration>> listStreamsInScope(final String scope, final long requestId) {
    Exceptions.checkNotNullOrEmpty(scope, "scope");
    OperationContext context = streamStore.createScopeContext(scope, requestId);
    return streamStore.listStreamsInScope(scope, context, executor);
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext)

Example 59 with OperationContext

use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.

the class ControllerService method getSegmentsBetweenStreamCuts.

public CompletableFuture<List<StreamSegmentRecord>> getSegmentsBetweenStreamCuts(Controller.StreamCutRange range, long requestId) {
    Preconditions.checkNotNull(range, "segment");
    Preconditions.checkArgument(!(range.getFromMap().isEmpty() && range.getToMap().isEmpty()));
    String scope = range.getStreamInfo().getScope();
    String stream = range.getStreamInfo().getStream();
    OperationContext context = streamStore.createStreamContext(scope, stream, requestId);
    return streamStore.getSegmentsBetweenStreamCuts(scope, stream, range.getFromMap(), range.getToMap(), context, executor);
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext)

Example 60 with OperationContext

use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.

the class ControllerService method isSegmentValid.

/**
 * Checks if the segment is still open.
 *
 * @param scope scope
 * @param stream stream name
 * @param segmentId segment to validate
 * @param requestId request id
 * @return future that when completed will indicate if the segment is open or not.
 */
public CompletableFuture<Boolean> isSegmentValid(final String scope, final String stream, final long segmentId, final long requestId) {
    Exceptions.checkNotNullOrEmpty(scope, "scope");
    Exceptions.checkNotNullOrEmpty(stream, "stream");
    OperationContext context = streamStore.createStreamContext(scope, stream, requestId);
    return streamStore.getActiveSegments(scope, stream, context, executor).thenApplyAsync(x -> x.stream().anyMatch(z -> z.segmentId() == segmentId), executor);
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) StreamSegmentRecord(io.pravega.controller.store.stream.records.StreamSegmentRecord) LoggerFactory(org.slf4j.LoggerFactory) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) SecureRandom(java.security.SecureRandom) Cluster(io.pravega.common.cluster.Cluster) TagLogger(io.pravega.common.tracing.TagLogger) StoreException(io.pravega.controller.store.stream.StoreException) Pair(org.apache.commons.lang3.tuple.Pair) Duration(java.time.Duration) Map(java.util.Map) SubscribersResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SubscribersResponse) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) ImmutableMap(com.google.common.collect.ImmutableMap) CompletionException(java.util.concurrent.CompletionException) RequestTracker(io.pravega.common.tracing.RequestTracker) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) RetriesExhaustedException(io.pravega.common.util.RetriesExhaustedException) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) List(java.util.List) SegmentRecord(io.pravega.controller.store.SegmentRecord) VersionedTransactionData(io.pravega.controller.store.stream.VersionedTransactionData) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) Futures(io.pravega.common.concurrent.Futures) SegmentId(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId) OperationContext(io.pravega.controller.store.stream.OperationContext) StreamMetrics(io.pravega.controller.metrics.StreamMetrics) CreateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateReaderGroupResponse) TransactionMetrics(io.pravega.controller.metrics.TransactionMetrics) Getter(lombok.Getter) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) ModelHelper(io.pravega.client.control.impl.ModelHelper) Exceptions(io.pravega.common.Exceptions) KeyValueTableConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfigResponse) ScaleStatusResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) CompletableFuture(java.util.concurrent.CompletableFuture) UpdateSubscriberStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateSubscriberStatus) ArrayList(java.util.ArrayList) BucketStore(io.pravega.controller.store.stream.BucketStore) NodeUri(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri) DeleteKVTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteKVTableStatus) ScaleMetadata(io.pravega.controller.store.stream.ScaleMetadata) DeleteStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) ScaleResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse) UpdateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateReaderGroupResponse) NameUtils(io.pravega.shared.NameUtils) Executor(java.util.concurrent.Executor) Timer(io.pravega.common.Timer) SegmentRange(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) TxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus) ClusterException(io.pravega.common.cluster.ClusterException) Preconditions(com.google.common.base.Preconditions) State(io.pravega.controller.store.stream.State) DeleteReaderGroupStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteReaderGroupStatus) RandomFactory(io.pravega.common.hash.RandomFactory) CreateKeyValueTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateKeyValueTableStatus) AllArgsConstructor(lombok.AllArgsConstructor) Comparator(java.util.Comparator) ReaderGroupConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfigResponse)

Aggregations

OperationContext (io.pravega.controller.store.stream.OperationContext)76 CompletableFuture (java.util.concurrent.CompletableFuture)53 Futures (io.pravega.common.concurrent.Futures)48 StreamMetadataStore (io.pravega.controller.store.stream.StreamMetadataStore)44 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)42 Exceptions (io.pravega.common.Exceptions)41 Collectors (java.util.stream.Collectors)41 UUID (java.util.UUID)39 StoreException (io.pravega.controller.store.stream.StoreException)38 List (java.util.List)38 TagLogger (io.pravega.common.tracing.TagLogger)37 LoggerFactory (org.slf4j.LoggerFactory)37 Preconditions (com.google.common.base.Preconditions)36 Map (java.util.Map)32 NameUtils (io.pravega.shared.NameUtils)31 VisibleForTesting (com.google.common.annotations.VisibleForTesting)27 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)26 State (io.pravega.controller.store.stream.State)26 CompletionException (java.util.concurrent.CompletionException)26 BucketStore (io.pravega.controller.store.stream.BucketStore)25