use of io.pravega.client.security.auth.DelegationTokenProvider in project pravega by pravega.
the class ByteStreamClientImpl method createByteStreamReaders.
private ByteStreamReader createByteStreamReaders(Segment segment) {
String delegationToken = Futures.getAndHandleExceptions(controller.getOrRefreshDelegationTokenFor(segment.getScope(), segment.getStream().getStreamName(), AccessOperation.READ), RuntimeException::new);
DelegationTokenProvider tokenProvider = DelegationTokenProviderFactory.create(delegationToken, controller, segment, AccessOperation.READ);
SegmentMetadataClient metaClient = metaStreamFactory.createSegmentMetadataClient(segment, tokenProvider);
long startOffset = Futures.getThrowingException(metaClient.getSegmentInfo()).getStartingOffset();
return new ByteStreamReaderImpl(inputStreamFactory.createInputStreamForSegment(segment, tokenProvider, startOffset), metaClient);
}
use of io.pravega.client.security.auth.DelegationTokenProvider in project pravega by pravega.
the class SegmentMetadataClientImpl method truncateSegmentAsync.
private CompletableFuture<SegmentTruncated> truncateSegmentAsync(Segment segment, long offset, DelegationTokenProvider tokenProvider) {
log.debug("Truncating segment: {} at offset {}", segment, offset);
RawClient connection = getConnection();
long requestId = connection.getFlow().getNextSequenceNumber();
return tokenProvider.retrieveToken().thenCompose(token -> connection.sendRequest(requestId, new TruncateSegment(requestId, segment.getScopedName(), offset, token))).thenApply(r -> transformReply(r, SegmentTruncated.class));
}
Aggregations