public static WireCommand readFrom(DataInput in, int length) throws IOException { long requestId = in.readLong(); long value = in.readLong(); return new SegmentAttribute(requestId, value); } }
order.verify(connection).send(new WireCommands.SegmentAttribute(2, WireCommands.NULL_ATTRIBUTE_VALUE)); order.verify(connection).send(new WireCommands.SegmentAttribute(3, 1)); order.verify(connection).send(new WireCommands.SegmentAttribute(5, 1)); order.verify(connection).send(new WireCommands.SegmentAttribute(7, 10)); order.verify(connection).send(new WireCommands.SegmentAttribute(9, WireCommands.NULL_ATTRIBUTE_VALUE));
@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)); }
@Override public long fetchProperty(SegmentAttribute attribute) { Exceptions.checkNotClosed(closed.get(), this); val future = RETRY_SCHEDULE.retryingOn(ConnectionFailedException.class) .throwingOn(NoSuchSegmentException.class) .runAsync(() -> getPropertyAsync(attribute.getValue(), delegationToken), connectionFactory.getInternalExecutor()); return Futures.getThrowingException(future).getValue(); }
@Test public void testSegmentAttribute() throws IOException { testCommand(new WireCommands.SegmentAttribute(l, l + 1)); }
@Override public Void answer(InvocationOnMock invocation) throws Throwable { processor.process(new WireCommands.SegmentAttribute(1, 123)); return null; } }).when(connection).sendAsync(Mockito.eq(new WireCommands.GetSegmentAttribute(1, segment.getScopedName(), attributeId, "")),