use of io.pravega.shared.protocol.netty.WireCommands.GetSegmentAttribute in project pravega by pravega.
the class SegmentMetadataClientImpl method getPropertyAsync.
private CompletableFuture<WireCommands.SegmentAttribute> getPropertyAsync(UUID attributeId, String delegationToken) {
long requestId = requestIdGenerator.get();
log.debug("Getting segment attribute: {}", attributeId);
RawClient connection = getConnection();
return connection.sendRequest(requestId, new GetSegmentAttribute(requestId, segmentId.getScopedName(), attributeId, delegationToken)).thenApply(r -> transformReply(r, WireCommands.SegmentAttribute.class));
}
use of io.pravega.shared.protocol.netty.WireCommands.GetSegmentAttribute in project pravega by pravega.
the class PravegaRequestProcessor method getSegmentAttribute.
@Override
public void getSegmentAttribute(GetSegmentAttribute getSegmentAttribute) {
long requestId = getSegmentAttribute.getRequestId();
String segmentName = getSegmentAttribute.getSegmentName();
UUID attributeId = getSegmentAttribute.getAttributeId();
if (!verifyToken(segmentName, getSegmentAttribute.getRequestId(), getSegmentAttribute.getDelegationToken(), READ, "Get StreamSegment Attribute")) {
return;
}
long trace = LoggerHelpers.traceEnter(log, "getSegmentAttribute", getSegmentAttribute);
segmentStore.getStreamSegmentInfo(segmentName, false, TIMEOUT).thenAccept(properties -> {
LoggerHelpers.traceLeave(log, "getSegmentAttribute", trace, properties);
if (properties == null) {
connection.send(new NoSuchSegment(requestId, segmentName));
} else {
Map<UUID, Long> attributes = properties.getAttributes();
Long value = attributes.get(attributeId);
if (value == null) {
value = WireCommands.NULL_ATTRIBUTE_VALUE;
}
connection.send(new SegmentAttribute(requestId, value));
}
}).exceptionally(e -> handleException(requestId, segmentName, "Get attribute", e));
}
Aggregations