use of io.pravega.shared.protocol.netty.WireCommands.SegmentAttribute in project pravega by pravega.
the class PravegaRequestProcessor method getSegmentAttribute.
@Override
public void getSegmentAttribute(GetSegmentAttribute getSegmentAttribute) {
long requestId = getSegmentAttribute.getRequestId();
String segmentName = getSegmentAttribute.getSegmentName();
AttributeId attributeId = getSegmentAttribute.getAttributeId() == null ? null : AttributeId.fromUUID(getSegmentAttribute.getAttributeId());
final String operation = "getSegmentAttribute";
if (!verifyToken(segmentName, getSegmentAttribute.getRequestId(), getSegmentAttribute.getDelegationToken(), operation)) {
return;
}
long trace = LoggerHelpers.traceEnter(log, operation, getSegmentAttribute);
segmentStore.getStreamSegmentInfo(segmentName, TIMEOUT).thenAccept(properties -> {
LoggerHelpers.traceLeave(log, operation, trace, properties);
if (properties == null) {
connection.send(new NoSuchSegment(requestId, segmentName, EMPTY_STACK_TRACE, -1L));
} else {
Long value = properties.getAttributes().get(attributeId);
if (value == null) {
value = WireCommands.NULL_ATTRIBUTE_VALUE;
}
connection.send(new SegmentAttribute(requestId, value));
}
}).exceptionally(e -> handleException(requestId, segmentName, operation, e));
}
Aggregations