use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method sealSegment.
/**
* This method sends segment sealed message for the specified segment.
*
* @param scope stream scope
* @param stream stream name
* @param segmentId number of segment to be sealed
* @param delegationToken the token to be presented to segmentstore.
* @param clientRequestId client-generated id for end-to-end tracing
* @return void
*/
public CompletableFuture<Void> sealSegment(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 qualifiedName = getQualifiedStreamSegmentName(scope, stream, segmentId);
final WireCommandType type = WireCommandType.SEAL_SEGMENT;
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
return sendRequest(connection, clientRequestId, new WireCommands.SealSegment(requestId, qualifiedName, delegationToken)).thenAccept(r -> handleReply(clientRequestId, r, connection, qualifiedName, WireCommands.SealSegment.class, type));
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method updateSegmentAttribute.
public CompletableFuture<WireCommands.SegmentAttributeUpdated> updateSegmentAttribute(String qualifiedName, UUID attributeId, long newValue, long existingValue, PravegaNodeUri uri, String delegationToken) {
final WireCommandType type = WireCommandType.UPDATE_SEGMENT_ATTRIBUTE;
RawClient connection = new RawClient(uri, connectionPool);
final long requestId = connection.getFlow().asLong();
WireCommands.UpdateSegmentAttribute request = new WireCommands.UpdateSegmentAttribute(requestId, qualifiedName, attributeId, newValue, existingValue, delegationToken);
return sendRequest(connection, requestId, request).thenApply(r -> {
handleReply(requestId, r, connection, qualifiedName, WireCommands.UpdateSegmentAttribute.class, type);
assert r instanceof WireCommands.SegmentAttributeUpdated;
return (WireCommands.SegmentAttributeUpdated) r;
});
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method updateTableEntries.
public CompletableFuture<List<TableSegmentKeyVersion>> updateTableEntries(final String tableName, final PravegaNodeUri uri, final List<TableSegmentEntry> entries, String delegationToken, final long clientRequestId) {
final WireCommandType type = WireCommandType.UPDATE_TABLE_ENTRIES;
List<Map.Entry<WireCommands.TableKey, WireCommands.TableValue>> wireCommandEntries = entries.stream().map(te -> {
final WireCommands.TableKey key = convertToWireCommand(te.getKey());
final WireCommands.TableValue value = new WireCommands.TableValue(te.getValue());
return new AbstractMap.SimpleImmutableEntry<>(key, value);
}).collect(Collectors.toList());
RawClient connection = new RawClient(uri, connectionPool);
final long requestId = connection.getFlow().asLong();
WireCommands.UpdateTableEntries request = new WireCommands.UpdateTableEntries(requestId, tableName, delegationToken, new WireCommands.TableEntries(wireCommandEntries), WireCommands.NULL_TABLE_SEGMENT_OFFSET);
return sendRequest(connection, clientRequestId, request).thenApply(rpl -> {
handleReply(clientRequestId, rpl, connection, tableName, WireCommands.UpdateTableEntries.class, type);
return ((WireCommands.TableEntriesUpdated) rpl).getUpdatedVersions().stream().map(TableSegmentKeyVersion::from).collect(Collectors.toList());
});
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method truncateSegment.
public CompletableFuture<Void> truncateSegment(final String scope, final String stream, final long segmentId, final long offset, 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.TRUNCATE_SEGMENT;
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
return sendRequest(connection, clientRequestId, new WireCommands.TruncateSegment(requestId, qualifiedStreamSegmentName, offset, delegationToken)).thenAccept(r -> handleReply(clientRequestId, r, connection, qualifiedStreamSegmentName, WireCommands.TruncateSegment.class, type));
}
use of io.pravega.client.connection.impl.RawClient in project pravega by pravega.
the class SegmentHelper method removeTableKeys.
/**
* This method sends a WireCommand to remove table keys.
*
* @param tableName Qualified table name.
* @param keys List of {@link TableSegmentKey}s to be removed. Only if all the elements in the list has version
* as {@link TableSegmentKeyVersion#NO_VERSION} then an unconditional update/removal is performed.
* Else an atomic conditional update (removal) is performed.
* @param delegationToken The token to be presented to the Segment Store.
* @param clientRequestId Request id.
* @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 with {@link WireCommandFailedException}.
*/
public CompletableFuture<Void> removeTableKeys(final String tableName, final List<TableSegmentKey> keys, String delegationToken, final long clientRequestId) {
final Controller.NodeUri uri = getTableUri(tableName);
final WireCommandType type = WireCommandType.REMOVE_TABLE_KEYS;
List<WireCommands.TableKey> keyList = keys.stream().map(x -> {
WireCommands.TableKey key = convertToWireCommand(x);
return key;
}).collect(Collectors.toList());
RawClient connection = new RawClient(ModelHelper.encode(uri), connectionPool);
final long requestId = connection.getFlow().asLong();
WireCommands.RemoveTableKeys request = new WireCommands.RemoveTableKeys(requestId, tableName, delegationToken, keyList, WireCommands.NULL_TABLE_SEGMENT_OFFSET);
return sendRequest(connection, clientRequestId, request).thenAccept(rpl -> handleReply(clientRequestId, rpl, connection, tableName, WireCommands.RemoveTableKeys.class, type));
}
Aggregations