use of io.pravega.shared.MetricsNames.RETENTION_FREQUENCY in project pravega by pravega.
the class StreamMetadataTasks method retention.
/**
* Method to check retention policy and generate new periodic cuts and/or truncate stream at an existing stream cut.
*
* @param scope scope
* @param stream stream
* @param policy retention policy
* @param recordingTime time of recording
* @param contextOpt operation context
* @param delegationToken token to be sent to segmentstore to authorize this operation.
* @return future.
*/
public CompletableFuture<Void> retention(final String scope, final String stream, final RetentionPolicy policy, final long recordingTime, final OperationContext contextOpt, final String delegationToken) {
Preconditions.checkNotNull(policy);
final OperationContext context = contextOpt == null ? streamMetadataStore.createContext(scope, stream) : contextOpt;
return streamMetadataStore.getStreamCutsFromRetentionSet(scope, stream, context, executor).thenCompose(retentionSet -> {
StreamCutRecord latestCut = retentionSet.stream().max(Comparator.comparingLong(StreamCutRecord::getRecordingTime)).orElse(null);
return checkGenerateStreamCut(scope, stream, context, latestCut, recordingTime, delegationToken).thenCompose(newRecord -> truncate(scope, stream, policy, context, retentionSet, newRecord, recordingTime));
}).thenAccept(x -> DYNAMIC_LOGGER.recordMeterEvents(nameFromStream(RETENTION_FREQUENCY, scope, stream), 1));
}
Aggregations