Search in sources :

Example 1 with SegmentPolicyUpdated

use of io.pravega.shared.protocol.netty.WireCommands.SegmentPolicyUpdated in project pravega by pravega.

the class PravegaRequestProcessor method updateSegmentPolicy.

@Override
public void updateSegmentPolicy(UpdateSegmentPolicy updateSegmentPolicy) {
    if (!verifyToken(updateSegmentPolicy.getSegment(), updateSegmentPolicy.getRequestId(), updateSegmentPolicy.getDelegationToken(), READ, "Update Segment Policy")) {
        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.debug("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(), "Update segment", e);
        } else {
            if (statsRecorder != null) {
                statsRecorder.policyUpdate(updateSegmentPolicy.getSegment(), updateSegmentPolicy.getScaleType(), updateSegmentPolicy.getTargetRate());
            }
        }
    });
}
Also used : AttributeUpdate(io.pravega.segmentstore.contracts.AttributeUpdate) SegmentPolicyUpdated(io.pravega.shared.protocol.netty.WireCommands.SegmentPolicyUpdated)

Aggregations

AttributeUpdate (io.pravega.segmentstore.contracts.AttributeUpdate)1 SegmentPolicyUpdated (io.pravega.shared.protocol.netty.WireCommands.SegmentPolicyUpdated)1