Search in sources :

Example 1 with FlowRequestData

use of com.alibaba.csp.sentinel.cluster.request.data.FlowRequestData in project Sentinel by alibaba.

the class DefaultClusterTokenClient method requestToken.

@Override
public TokenResult requestToken(Long flowId, int acquireCount, boolean prioritized) {
    if (notValidRequest(flowId, acquireCount)) {
        return badRequest();
    }
    FlowRequestData data = new FlowRequestData().setCount(acquireCount).setFlowId(flowId).setPriority(prioritized);
    ClusterRequest<FlowRequestData> request = new ClusterRequest<>(ClusterConstants.MSG_TYPE_FLOW, data);
    try {
        TokenResult result = sendTokenRequest(request);
        logForResult(result);
        return result;
    } catch (Exception ex) {
        ClusterClientStatLogUtil.log(ex.getMessage());
        return new TokenResult(TokenResultStatus.FAIL);
    }
}
Also used : TokenResult(com.alibaba.csp.sentinel.cluster.TokenResult) ClusterRequest(com.alibaba.csp.sentinel.cluster.request.ClusterRequest) FlowRequestData(com.alibaba.csp.sentinel.cluster.request.data.FlowRequestData) ParamFlowRequestData(com.alibaba.csp.sentinel.cluster.request.data.ParamFlowRequestData)

Aggregations

TokenResult (com.alibaba.csp.sentinel.cluster.TokenResult)1 ClusterRequest (com.alibaba.csp.sentinel.cluster.request.ClusterRequest)1 FlowRequestData (com.alibaba.csp.sentinel.cluster.request.data.FlowRequestData)1 ParamFlowRequestData (com.alibaba.csp.sentinel.cluster.request.data.ParamFlowRequestData)1