@Override public void updateSegmentPolicy(UpdateSegmentPolicy updateSegmentPolicy) { final String operation = "updateSegmentPolicy"; if (!verifyToken(updateSegmentPolicy.getSegment(), updateSegmentPolicy.getRequestId(), updateSegmentPolicy.getDelegationToken(), operation)) { return; } Collection<AttributeUpdate> attributes = Arrays.asList( new AttributeUpdate(SCALE_POLICY_TYPE, AttributeUpdateType.Replace, (long) updateSegmentPolicy.getScaleType()), new AttributeUpdate(SCALE_POLICY_RATE, AttributeUpdateType.Replace, updateSegmentPolicy.getTargetRate())); log.info(updateSegmentPolicy.getRequestId(), "Updating segment policy {} ", updateSegmentPolicy); segmentStore.updateAttributes(updateSegmentPolicy.getSegment(), attributes, TIMEOUT) .thenRun(() -> connection.send(new SegmentPolicyUpdated(updateSegmentPolicy.getRequestId(), updateSegmentPolicy.getSegment()))) .whenComplete((r, e) -> { if (e != null) { handleException(updateSegmentPolicy.getRequestId(), updateSegmentPolicy.getSegment(), operation, e); } else { if (statsRecorder != null) { statsRecorder.policyUpdate(updateSegmentPolicy.getSegment(), updateSegmentPolicy.getScaleType(), updateSegmentPolicy.getTargetRate()); } } }); }