use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method getTableSegmentInfo.
/**
* This method sends a WireCommand to get information about a Table Segment.
*
* @param tableName Qualified table name.
* @param delegationToken The token to be presented to the segmentstore.
* @param clientRequestId Request id.
* @return A CompletableFuture that, when completed successfully, will return information about the Table Segment.
* 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 with {@link WireCommandFailedException}.
*/
public CompletableFuture<WireCommands.TableSegmentInfo> getTableSegmentInfo(final String tableName, String delegationToken, final long clientRequestId) {
final Controller.NodeUri uri = getTableUri(tableName);
final WireCommandType type = WireCommandType.GET_TABLE_SEGMENT_INFO;
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
// All Controller Metadata Segments are non-sorted.
return sendRequest(connection, clientRequestId, new WireCommands.GetTableSegmentInfo(requestId, tableName, delegationToken)).thenApply(r -> {
handleReply(clientRequestId, r, connection, tableName, WireCommands.GetTableSegmentInfo.class, type);
assert r instanceof WireCommands.TableSegmentInfo;
return (WireCommands.TableSegmentInfo) r;
});
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method deleteSegment.
public CompletableFuture<Void> deleteSegment(final String scope, final String stream, final long segmentId, final String delegationToken, final long clientRequestId) {
final Controller.NodeUri uri = getSegmentUri(scope, stream, segmentId);
final String qualifiedStreamSegmentName = getQualifiedStreamSegmentName(scope, stream, segmentId);
final WireCommandType type = WireCommandType.DELETE_SEGMENT;
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
return sendRequest(connection, clientRequestId, new WireCommands.DeleteSegment(requestId, qualifiedStreamSegmentName, delegationToken)).thenAccept(r -> handleReply(clientRequestId, r, connection, qualifiedStreamSegmentName, WireCommands.DeleteSegment.class, type));
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method deleteTableSegment.
/**
* This method sends a WireCommand to delete a table segment.
*
* @param tableName Qualified table name.
* @param mustBeEmpty Flag to check if the table segment should be empty before deletion.
* @param delegationToken The token to be presented to the segmentstore.
* @param clientRequestId Request id.
* @return A CompletableFuture that, when completed normally, will indicate the table segment deletion completed
* successfully. 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 with {@link WireCommandFailedException}.
*/
public CompletableFuture<Void> deleteTableSegment(final String tableName, final boolean mustBeEmpty, String delegationToken, final long clientRequestId) {
final Controller.NodeUri uri = getTableUri(tableName);
final WireCommandType type = WireCommandType.DELETE_TABLE_SEGMENT;
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
return sendRequest(connection, clientRequestId, new WireCommands.DeleteTableSegment(requestId, tableName, mustBeEmpty, delegationToken)).thenAccept(rpl -> handleReply(clientRequestId, rpl, connection, tableName, WireCommands.DeleteTableSegment.class, type));
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method getSegmentAttribute.
public CompletableFuture<WireCommands.SegmentAttribute> getSegmentAttribute(String qualifiedName, UUID attributeId, PravegaNodeUri uri, String delegationToken) {
final WireCommandType type = WireCommandType.GET_SEGMENT_ATTRIBUTE;
RawClient connection = new RawClient(uri, connectionPool);
final long requestId = connection.getFlow().asLong();
WireCommands.GetSegmentAttribute request = new WireCommands.GetSegmentAttribute(requestId, qualifiedName, attributeId, delegationToken);
return sendRequest(connection, requestId, request).thenApply(r -> {
handleReply(requestId, r, connection, qualifiedName, WireCommands.GetSegmentAttribute.class, type);
assert r instanceof WireCommands.SegmentAttribute;
return (WireCommands.SegmentAttribute) r;
});
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method createSegment.
public CompletableFuture<Void> createSegment(final String scope, final String stream, final long segmentId, final ScalingPolicy policy, final String controllerToken, final long clientRequestId, final long rolloverSizeBytes) {
final String qualifiedStreamSegmentName = getQualifiedStreamSegmentName(scope, stream, segmentId);
final Controller.NodeUri uri = getSegmentUri(scope, stream, segmentId);
final WireCommandType type = WireCommandType.CREATE_SEGMENT;
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
Pair<Byte, Integer> extracted = extractFromPolicy(policy);
return sendRequest(connection, clientRequestId, new WireCommands.CreateSegment(requestId, qualifiedStreamSegmentName, extracted.getLeft(), extracted.getRight(), controllerToken, rolloverSizeBytes)).thenAccept(r -> handleReply(clientRequestId, r, connection, qualifiedStreamSegmentName, WireCommands.CreateSegment.class, type));
}
Aggregations