@Override
public void getSegmentAttribute(GetSegmentAttribute getSegmentAttribute) {
long requestId = getSegmentAttribute.getRequestId();
String segmentName = getSegmentAttribute.getSegmentName();
UUID attributeId = 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));
} 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, operation, e));
}