use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.
the class ControllerService method getSegmentsImmediatelyFollowing.
public CompletableFuture<Map<SegmentRange, List<Integer>>> getSegmentsImmediatelyFollowing(SegmentId segment) {
Preconditions.checkNotNull(segment, "segment");
OperationContext context = streamStore.createContext(segment.getStreamInfo().getScope(), segment.getStreamInfo().getStream());
return streamStore.getSuccessors(segment.getStreamInfo().getScope(), segment.getStreamInfo().getStream(), segment.getSegmentNumber(), context, executor).thenComposeAsync(successors -> Futures.keysAllOfWithResults(successors.entrySet().stream().collect(Collectors.toMap(entry -> streamStore.getSegment(segment.getStreamInfo().getScope(), segment.getStreamInfo().getStream(), entry.getKey(), context, executor).thenApply(seg -> ModelHelper.createSegmentRange(segment.getStreamInfo().getScope(), segment.getStreamInfo().getStream(), seg.getNumber(), seg.getKeyStart(), seg.getKeyEnd())), Map.Entry::getValue))), executor);
}
use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.
the class StreamCutBucketService method performRetention.
private CompletableFuture<Void> performRetention(StreamImpl stream) {
log.debug("Periodic background processing for retention called for stream {}/{}", stream.getScope(), stream.getStreamName());
OperationContext context = streamMetadataStore.createContext(stream.getScope(), stream.getStreamName());
return RetryHelper.withRetriesAsync(() -> streamMetadataStore.getConfiguration(stream.getScope(), stream.getStreamName(), context, executor).thenCompose(config -> streamMetadataTasks.retention(stream.getScope(), stream.getStreamName(), config.getRetentionPolicy(), System.currentTimeMillis(), context, this.streamMetadataTasks.retrieveDelegationToken())).exceptionally(e -> {
log.warn("Exception thrown while performing auto retention for stream {} ", stream, e);
throw new CompletionException(e);
}), RetryHelper.UNCONDITIONAL_PREDICATE, 5, executor).exceptionally(e -> {
log.warn("Unable to perform retention for stream {}. Ignoring, retention will be attempted in next cycle.", stream, e);
return null;
});
}
use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.
the class ControllerService method getSegmentsAtHead.
public CompletableFuture<Map<SegmentId, Long>> getSegmentsAtHead(final String scope, final String stream, long requestId) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
// First fetch segments active at specified timestamp from the specified stream.
// Divide current segments in segmentFutures into at most count positions.
OperationContext context = streamStore.createStreamContext(scope, stream, requestId);
return streamStore.getSegmentsAtHead(scope, stream, context, executor).thenApply(segments -> {
return segments.entrySet().stream().collect(Collectors.toMap(entry -> ModelHelper.createSegmentId(scope, stream, entry.getKey().segmentId()), Map.Entry::getValue));
});
}
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);
}
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()));
}
Aggregations