use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method createTransaction.
public CompletableFuture<Void> createTransaction(final String scope, final String stream, final long segmentId, final UUID txId, final String delegationToken, final long clientRequestId, final long rolloverSizeBytes) {
final Controller.NodeUri uri = getSegmentUri(scope, stream, segmentId);
final String transactionName = getTransactionName(scope, stream, segmentId, txId);
final WireCommandType type = WireCommandType.CREATE_SEGMENT;
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
WireCommands.CreateSegment request = new WireCommands.CreateSegment(requestId, transactionName, WireCommands.CreateSegment.NO_SCALE, 0, delegationToken, rolloverSizeBytes);
return sendRequest(connection, clientRequestId, request).thenAccept(r -> handleReply(clientRequestId, r, connection, transactionName, WireCommands.CreateSegment.class, type));
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class AdminSegmentHelper method listStorageChunks.
/**
* This methods sends a WireCommand to get the list of storage chunks under the given segment name.
*
* @param qualifiedName StreamSegmentName
* @param uri The uri of the Segment Store instance.
* @param delegationToken The token to be presented to the Segment Store.
* @return A CompletableFuture that return the list of storage chunks as a WireCommand.
*/
public CompletableFuture<WireCommands.StorageChunksListed> listStorageChunks(String qualifiedName, PravegaNodeUri uri, String delegationToken) {
final WireCommandType type = WireCommandType.LIST_STORAGE_CHUNKS;
RawClient connection = new RawClient(uri, connectionPool);
final long requestId = connection.getFlow().asLong();
WireCommands.ListStorageChunks request = new WireCommands.ListStorageChunks(qualifiedName, delegationToken, requestId);
return sendRequest(connection, requestId, request).thenApply(r -> {
handleReply(requestId, r, connection, qualifiedName, WireCommands.ListStorageChunks.class, type);
assert r instanceof WireCommands.StorageChunksListed;
return (WireCommands.StorageChunksListed) r;
});
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class AdminSegmentHelper method flushToStorage.
/**
* This method sends a WireCommand to flush the container corresponding to the given containerId to storage.
*
* @param containerId The Id of the container that needs to be persisted to storage.
* @param uri The uri of the Segment Store instance.
* @param delegationToken The token to be presented to the Segment Store.
* @return A CompletableFuture that will complete normally when the provided keys are deleted.
* If the operation failed, the future will be failed with the causing exception. If the exception can be
* retried then the future will be failed.
*/
public CompletableFuture<WireCommands.StorageFlushed> flushToStorage(int containerId, PravegaNodeUri uri, String delegationToken) {
final WireCommandType type = WireCommandType.FLUSH_TO_STORAGE;
RawClient connection = new RawClient(uri, connectionPool);
final long requestId = connection.getFlow().asLong();
WireCommands.FlushToStorage request = new WireCommands.FlushToStorage(containerId, delegationToken, requestId);
return sendRequest(connection, requestId, request).thenApply(r -> {
handleReply(requestId, r, connection, null, WireCommands.FlushToStorage.class, type);
assert r instanceof WireCommands.StorageFlushed;
return (WireCommands.StorageFlushed) r;
});
}
use of io.pravega.client.connection.impl.RawClient 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));
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentMetadataClientImpl method getPropertyAsync.
private CompletableFuture<WireCommands.SegmentAttribute> getPropertyAsync(UUID attributeId) {
log.debug("Getting segment attribute: {}", attributeId);
RawClient connection = getConnection();
long requestId = connection.getFlow().getNextSequenceNumber();
return tokenProvider.retrieveToken().thenCompose(token -> connection.sendRequest(requestId, new GetSegmentAttribute(requestId, segmentId.getScopedName(), attributeId, token))).thenApply(r -> transformReply(r, WireCommands.SegmentAttribute.class));
}
Aggregations